Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save theresajayne/34e0573a213435c70f0b45cc0dfaacdf to your computer and use it in GitHub Desktop.
Save theresajayne/34e0573a213435c70f0b45cc0dfaacdf to your computer and use it in GitHub Desktop.
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$housenum = $_POST["housenum"];
$postcode = $_POST["postcode"];
$con = mysqli_connect("localhost","dbuser","dbpassword","table");
if (mysqli_connect_errno())
{
die('Could not connect: ' . mysqli_connect_error());
}
$sql="INSERT INTO swimming (name, email,housenum,postcode) VALUES (:name,:email,:housenum,:postcode)";
if($stmt = $con->prepare($sql))
{
$stmt->bind_param(":name","s",$name);
$stmt->bind_param(":email","s",$email);
$stmt->bind_param(":housenum","s",$housenum);
$stmt->bind_param(":postcode","s",$postcode);
}
else
{
echo "Error in SQL\n";
die($stmt->error);
}
if ($stmt->execute()) {
echo "Thank you for Voting";
} else {
echo $stmt->error;
}
mysqli_close($con);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment