Created
May 29, 2016 08:50
-
-
Save theresajayne/34e0573a213435c70f0b45cc0dfaacdf to your computer and use it in GitHub Desktop.
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 | |
| $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