Guest User

Untitled

a guest
Nov 26th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. //check email
  2. if (isset($_POST['email'])) {
  3. $email = stripslashes($_POST['email']);
  4. $email = trim($email);
  5.  
  6. //check email format
  7. if (strlen($email) == 0 || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
  8. echo "<p>Your email number is required and must be a valid format.</p>n";
  9. ++$FormErrorCount;
  10. }
  11. //check to see if email already exists
  12. include("inc_db_conference.php");
  13. $DBConnect = new mysqli ($config['db_host'], $config['db_user'], $config['db_password'], $config['db_name']);
  14. if($DBConnect !== FALSE) {
  15. $TableName = "personal";
  16. $select = "SELECT email FROM $TableName WHERE email=$email";
  17. }
  18.  
  19. $QueryResult = mysqli_query($DBConnect, $select);
  20. if($QueryResult !== FALSE) {
  21. echo "<p>This email is already being used. Go back to the form and use a different email to register.</p>";
  22. ++$FormErrorCount;
  23. }
  24. //mysqli_close($DBConnect);
  25.  
  26. } else {
  27. echo "<p>Form submittal error (No 'email' field)!</p>n";
  28. ++$FormErrorCount;
  29. }
  30.  
  31. //if data is present, send to database
  32. if ($FormErrorCount == 0) {
  33.  
  34. include("inc_db_conference.php");
  35. $DBConnect = new mysqli ($config['db_host'], $config['db_user'], $config['db_password'], $config['db_name']);
  36.  
  37. if($DBConnect !== FALSE) {
  38. $TableName = "personal";
  39. $SQLstring = "INSERT INTO $TableName "."(firstName, lastName, address, city, state, zip, phone, email) VALUES ".
  40. "('$firstName', '$lastName', '$street', '$city', '$state', '$zip', '$phone', '$email')";
  41. }
  42.  
  43. $QueryResult = mysqli_query($DBConnect, $SQLstring);
  44. if($QueryResult === FALSE)
  45. echo "<p>Unable to insert the values into the personal information table. Error code ".mysqli_errno($DBConnect).": ".mysqli_error($DBConnect)."</p>";
  46. else
  47. echo "<p>Your information has been saved. Please continue with your registration <a href='CompanyInfo.php?".SID."'>on the next page</a>.</p>";
  48. }
  49. mysqli_close($DBConnect);
  50.  
  51. } else {
  52. echo "<p> Please return to the <a href='PersonalInfo.php?".SID."'> Personal Information form</a> to correct the errors mentioned above.</p>";
Add Comment
Please, Sign In to add comment