Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $serverName = "127.0.0.1"; //address for MySQL server
- $user = "dtgouff";
- $pass = "B1llWaterson";
- $dbName ="dtgouff";
- $fname = ($_POST["firstName"]);
- $lname = ($_POST["lastName"]);
- $address = ($_POST["add"]);
- $loccity = ($_POST["city"]);
- $locstate = ($_POST["state"]);
- $zcode = ($_POST["zip"]);
- $telephone = ($_POST["phoneNumber"]);
- $subemail = ($_POST["email"]);
- $user_chars = "#[^a-zA-Z0-9_\-]#";
- $email_chars = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";
- function errorMsg()
- {
- $con = mysql_connect('127.0.0.1', 'dtgouff', 'B1llWaterson');
- if (!$con)
- {
- die('Could not connect: ' . mysql_error());
- }
- else
- {
- if (!empty($_POST))
- {
- if ((empty($_POST["firstName"]))||(empty($_POST["lastName"]))||(empty($_POST["add"]))||(empty($_POST["city"]))||(empty($_POST["zip"]))||(empty($_POST["phoneNumber"]))||(empty($_POST["email"])))
- {
- die('Some fields were missing; go <a href="register.php">back here</a> and start again.');
- }
- else
- {
- $DB_DB ="dtgouff";
- $FNAME = ($_POST["firstName"]);
- $LNAME = ($_POST["lastName"]);
- $ADDRESS = ($_POST["add"]);
- $LOCCITY = ($_POST["city"]);
- $LOCSTATE = ($_POST["state"]);
- $ZCODE = ($_POST["zip"]);
- $TELEPHONE = ($_POST["phoneNumber"]);
- $SUBEMAIL = ($_POST["email"]);
- $user_chars = "#[^a-zA-Z0-9_\-]#";
- $email_chars = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";
- $FORMAT = ($_POST["optIn"]);
- if (strlen($ZCODE) != 5) // check zip code
- {
- die('Invalid zip code; go <a href="register.php">back here</a> and start again.');
- }
- if (strlen($TELEPHONE) <= 9) // check phone number
- {
- die('Invalid phone number; go <a href="register.php">back here</a> and start again.');
- }
- if (strlen($TELEPHONE) >= 18) // check phone number
- {
- die('Invalid phone number; go <a href="register.php">back here</a> and start again.');
- }
- if(preg_match($user_chars,$FNAME)) // check first name
- {
- die('Invalid first name; go <a href="register.php">back here</a> and start again.');
- }
- if(preg_match($user_chars,$LNAME))// check last name
- {
- die('Invalid last name; go <a href="register.php">back here</a> and start again.');
- }
- if(preg_match($user_chars,$LOCCITY))// check city
- {
- die('Invalid city; go <a href="register.php">back here</a> and start again.');
- }
- else
- {
- unset($qry);
- $SUBEMAIL = mysql_real_escape_string($SUBEMAIL);
- $register_sql = "insert into " . mysql_real_escape_string($DB_DB) . ".marketing (fname,lname,address,loccity,locstate,zcode,telephone,format,subemail) values ('" . $FNAME . "','" . $LNAME . "','" . $ADDRESS . "','" . $LOCCITY . "','" . $LOCSTATE . "','" . $ZCODE . "','" . $TELEPHONE . "','" . $FORMAT . "','" . $SUBEMAIL . "')";
- $qry = @mysql_query($register_sql, $con);
- if (!$qry)
- {
- die("Error creating account: " . mysql_error());
- }
- else{
- if (FORMAT == "1") // opt in for flyer
- {
- echo 'Thank you for signing up for our flyer!<br />';
- }
- if ($FORMAT == "2") //opt in for email
- {
- echo 'Thank you for signing up for our email!<br />';
- }
- else // opt in for email and flyer
- {
- echo 'Thank you for signing up for our email and flyer!<br />';
- }
- }
- }
- }
- }
- }
- }
- errorMsg(); // Write function
- mysql_close($con); // terminate MySQL connection
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement