Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
1
Answer
How to pass datepicker value in form POST methed to PHP ?
Kashif Ali
6y
681
1
Reply
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
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Could not open input file: artisan
How to Validate Phone Numbers in PHP