Created
October 8, 2014 16:29
-
-
Save sasasa671/1a643b6575f364c28373 to your computer and use it in GitHub Desktop.
post.php
This file contains hidden or 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 | |
// Connec to MYSQL Database | |
$con=mysqli_connect("","","","bdays"); | |
// Check connection to MySQL Server | |
if (mysqli_connect_errno()) { | |
echo "MySQL Failed To Start - Error" . mysqli_connect_error(); | |
} | |
// varis | |
$name = mysqli_real_escape_string($con, $_POST['name']); | |
// bday | |
$birthday = mysqli_real_escape_string($con, $_POST['birthday']); | |
// insert $name & $birthday inputs into bdays | |
$sql="INSERT INTO bdays (name, birthday) | |
VALUES ('$name', '$birthday')"; | |
// if mysql fails statement | |
if (!mysqli_query($con,$sql)) { | |
die('Error: ' . mysqli_error($con)); | |
} | |
// Display a thank you or pass onto another page | |
echo "Thank you; You've successfully been added to the database."; | |
// close MySQL | |
mysqli_close($con); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment