Skip to content

Instantly share code, notes, and snippets.

@sasasa671
Created October 8, 2014 16:29
Show Gist options
  • Save sasasa671/1a643b6575f364c28373 to your computer and use it in GitHub Desktop.
Save sasasa671/1a643b6575f364c28373 to your computer and use it in GitHub Desktop.
post.php
<?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