Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $dbusername = "";
- $dbpassword = "";
- $dbname = "";
- $first_name = $_POST ['first_name'];
- $last_name = $_POST ['last_name'];
- $email = $_POST ['email'];
- $optin = $_POST ['optin'];
- $conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
- if ($conn->connect_error){
- die("Connection Error: " . $conn->connect_error);
- }
- if (empty($first_name)) {
- echo "First name cannot be left blank";
- die();
- }
- if (empty($last_name)) {
- echo "Last name cannot be left blank";
- die();
- }
- if (empty($email)) {
- echo "Email cannot be left blank";
- die();
- }
- $captcha = check_input($_POST['captcha']);
- if (!captcha ==("/5/", $captcha))
- {
- echo ("Wrong Answer");
- }
- $data = "INSERT INTO registration (first_name, last_name, email, optin)
- VALUES ('$first_name', '$last_name', '$email', '$optin')";
- if ($conn->query($data) === TRUE) {
- echo readfile("thanks.html");
- }
- else {
- echo "Connection Error: " . $data . "<br>" . $conn->error;
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement