TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kashif Ali
NA
78
9.9k
How to pass datepicker value in form POST methed to PHP ?
Dec 5 2018 4:53 AM
here's my HTML form
<meta charset=
"utf-8"
>
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<link rel=
"stylesheet"
href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"
></script>
<script type=
"text/javascript"
>
$(
function
() {
$(
'#datetimepicker1'
).datetimepicker();
});
</script>
<script src=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
></script>
<!-- <link rel=
"stylesheet"
type=
"text/css"
href=
"css/bootstrap-datetimepicker.css"
> -->
<script type=
"text/javascript"
src=
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"
></script>
<link rel=
"stylesheet"
type=
"text/css"
href=
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.43/css/bootstrap-datetimepicker.min.css"
>
<link rel=
"stylesheet"
type=
"text/css"
href=
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.43/css/bootstrap-datetimepicker-standalone.css"
>
<script type=
"text/javascript"
src=
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.43/js/bootstrap-datetimepicker.min.js"
></script>
<script>
$(document).ready(
function
(){
$(
'[data-toggle="tooltip"]'
).tooltip();
});
</script>
<form action=
"one.php"
method=
"POST"
>
<div
class
=
"col-md-6"
>
<div
class
=
"form-group"
>
<label
for
=
"name"
>Event Title:</label>
<input type=
"text"
class
=
"form-control"
id=
"first_name"
placeholder=
"Should be 10 character"
required=
""
name=
"title"
maxlength=
"10"
>
</div>
<div
class
=
"form-group"
>
<label
for
=
"name"
>Client Name:</label>
<input type=
"text"
class
=
"form-control"
id=
"first_name"
placeholder=
"Enter Name"
name=
"name"
>
</div>
<div
class
=
"form-group"
>
<label
for
=
"text"
>Task:</label>
<input type=
"text"
class
=
"form-control"
name=
"task"
placeholder=
"Enter Task"
>
</div>
</div>
<div
class
=
"col-md-6"
>
<div
class
=
"form-group"
>
<label
for
=
"text"
>Set Date & Time:</label>
<div
class
=
"form-group"
>
<div
class
=
'input-group date'
id=
'datetimepicker1'
name=
"datepicker"
value=
"date"
>
<input type=
'text'
class
=
"form-control"
id=
"datepicker1"
name=
"datepicker"
value=
"date"
/>
<span
class
=
"input-group-addon"
>
<span
class
=
"glyphicon glyphicon-calendar"
></span>
</span>
</div>
</div>
</div>
<div
class
=
"form-group"
>
<label
for
=
"text"
>Department:</label>
<input type=
"text"
class
=
"form-control"
name=
"department"
placeholder=
"Select department "
>
</div>
<div
class
=
"form-group"
>
<label
for
=
"text"
>Assign to:</label>
<input type=
"text"
class
=
"form-control"
name=
"assign"
placeholder=
"Select"
>
</div>
<br><br>
<button type=
"submit"
name=
"submitform"
class
=
"btn btn-default"
style=
"float:right;width:auto; padding:10px; font-size:16px; background-color:rgba(0,0,0,0.8); color:white;"
>Submit</button>
</form>
AND Here's PHP
<?php
$servername
=
"localhost"
;
$username
=
"root"
;
$password
=
""
;
$db
=
"admin"
;
// Create connection
$conn
=
new
mysqli(
$servername
,
$username
,
$password
,
$db
);
if
(isset(
$_POST
[
'submitform'
])){
$title
=
$_POST
[
'title'
];
$name
=
$_POST
[
'name'
];
$department
=
$_POST
[
'department'
];
$task
=
$_POST
[
'task'
];
$date
=
$_POST
[
'datepicker'
];
$assign
=
$_POST
[
'assign'
];
$now
=
date
(
'm/d/Y h:i:s a'
, time());
$query
= "CREATE EVENT IF NOT EXISTS
$title
ON SCHEDULE AT
'$date'
DO
INSERT INTO task(name,department,task,assign,deadline,created_at) VALUES (
'$name'
,
'$department'
,
'$task'
,
'$assign'
,
'$date'
,
'$now'
)
;";
mysqli_query(
$conn
,
$query
);
echo
"<center><br>Event has been created.<br/> You're notified that this will be fired automatically on your set date !<br/><br/>Redirecting back in 5 seconds ..."
;
header(
"Refresh: 1; url=test2.php"
);
mysqli_close(
$conn
);
};
?>
Please guide, Please
Reply
Answers (
1
)
Could not open input file: artisan
How to Validate Phone Numbers in PHP