Last active
September 24, 2015 13:33
-
-
Save JamesVanWaza/23c92050571932f2216e to your computer and use it in GitHub Desktop.
Insert jQuery Date into MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<form action="test.php" method="post"> | |
<div class="row"> | |
<div class="large-12-columns"> | |
<fieldset> | |
<legend>Date of Presentation</legend> | |
<label for="">Presentation Date</label> | |
<input type="text" name="jquerydatepicker" class="selector" value="<?php if (isset($_POST['jquerydatepicker'])) { | |
echo $_POST['jquerydatepicker']; | |
} | |
?>" placeholder="When the event was held"/> | |
</fieldset> | |
</div> | |
<div class="large-12-columns"> | |
<div class="row"> | |
<div class="small-12 medium-12 large-12 columns"> | |
<button class="tiny round right firstbutton" name="button">Next Page <i class="fa fa-angle-double-right"></i></button> | |
</div> | |
</div> | |
</div> | |
</div> | |
</form> | |
<script src="bower_components/jquery/dist/jquery.min.js"></script> | |
<script src="bower_components/foundation/js/foundation.min.js"></script> | |
<script type="text/javascript" src="bower_components/chosen/chosen.jquery.min.js"></script> | |
<script type="text/javascript" src="https://use.typekit.net/yiz1wur.js"></script> | |
<script type="text/javascript">try{Typekit.load({ async: true });}catch(e){}</script> | |
<script src="jquery-ui-1.11.4/jquery-ui.min.js"></script> | |
<script> | |
jQuery(document).ready(function($) { | |
$(document).foundation(); | |
$(".selector").datepicker({ | |
dateFormat: "yy-mm-dd" | |
}); | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php require 'mysqli-connect.php'; | |
if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
/** Variables */ | |
$pdate = isset($_POST['jquerydatepicker']) ? $_POST['jquerydatepicker'] : ''; | |
$q = "INSERT INTO `testdate` (id, pdate, date_created) | |
VALUES (NULL, '$pdate', NOW())"; | |
$result = @mysqli_query($dbcon, $q); /** Run the Query **/ | |
if ($result) { | |
// If it ran OK. | |
echo var_dump($_POST); | |
echo '<div data-alert class="alert-box"> | |
Success, 1 step completed !!! 3 to Go | |
<a href="#" class="close">×</a> | |
</div>'; | |
exit(); | |
} else { | |
// Public message: | |
echo '<div data-alert class="alert-box alert"> | |
You could not be registered due to a system error. We apologize for any inconvenience. | |
<a href="#" class="close">×</a> | |
</div>'; | |
// Debugging message: | |
echo '<p class="text-center error">' . mysqli_error($dbcon) . '<br><br>Query: ' . $q . '</p>'; | |
} // End of if ($r) IF. | |
} | |
?> | |
<script src="bower_components/jquery/dist/jquery.min.js"></script> | |
<script src="bower_components/foundation/js/foundation.min.js"></script> | |
<script type="text/javascript" src="https://use.typekit.net/yiz1wur.js"></script> | |
<script type="text/javascript">try{Typekit.load({ async: true });}catch(e){}</script> | |
<script src="jquery-ui-1.11.4/jquery-ui.min.js"></script> | |
<script> | |
jQuery(document).ready(function($) { | |
$(document).foundation(); | |
}); | |
</script> | |
<?php include 'footer.php';?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The name of your input field is "jquerydatepicker", so $pdate in test.php should be $_POST['jquerydatepicker'].