Advertisement
commandrea

PHP FORM

Feb 27th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. <head></head>
  2.  
  3. <?php
  4. // Make a MySQL Connection
  5. $con = mysql_connect("xxx", "volunteers2012", "xxx");
  6. if (!$con)
  7. {
  8. die('Could not connect: ' . mysql_error());
  9. }
  10.  
  11. mysql_select_db("volunteers2012", $con);
  12.  
  13. mysql_real_escape_string($unescaped_string, $con);
  14.  
  15. function checkEmail($email) {
  16. $email = mysql_real_escape_string($email);
  17.  
  18. $sql = mysql_query("SELECT * FROM vols2012 WHERE email='$email'");
  19.  
  20. if (mysql_num_rows($sql) == 0) {
  21. return true;
  22. }
  23.  
  24. return false;
  25. }
  26.  
  27. if (checkEmail($_POST['email'])) {
  28. // Continue insert
  29. } else {
  30. die( "There is already a user with that email!" ) ;
  31. }
  32.  
  33. function check_input($data, $problem='')
  34. {
  35. $data = trim($data);
  36. $data = stripslashes($data);
  37. $data = htmlspecialchars($data);
  38. }
  39.  
  40.  
  41. $sql="INSERT INTO vols2012 (id, agreeName, last_name, first_name, age, gender, phone, email, facebook, street_no, city, state, zip, attended, volbefore, volbeforeyes, cpr, tabc, skills, avail, shirt)
  42.  
  43. VALUES ('', '$_POST[agreeName]', '$_POST[last_name]', '$_POST[first_name]', '$_POST[age]', '$_POST[gender]', '$_POST[phone]', '$_POST[email]', '$_POST[facebook]', '$_POST[street_no]', '$_POST[city]', '$_POST[state]', '$_POST[zip]', '$_POST[attended]', '$_POST[volbefore]', '$_POST[volbeforeyes]', '$_POST[cpr]', '$_POST[tabc]', '$_POST[skills]', '$_POST[avail]', '$_POST[shirt]')";
  44.  
  45. if(mysql_query($sql))
  46.  
  47. ?>
  48.  
  49. <?php
  50. $agreeName = check_input($_POST['agreeName'], "Form incomplete. You did not add your electronic signature. Please go back and sign the release at the end of the form.");
  51. $lastname = check_input($_POST['last_name'], "Form incomplete. Enter your last name.");
  52. $firstname = check_input($_POST['first_name'], "Form incomplete. Enter your first name.");
  53. $age = check_input($_POST['age'], "Form incomplete. Enter your age.");
  54. $gender = check_input($_POST['gender'], "Form incomplete. Enter your gender.");
  55. $phone = check_input($_POST['phone'], "Form incomplete. Enter your phone number.");
  56. $email = check_input($_POST['email'], "Form incomplete. Enter your email address.");
  57. $street_no = check_input($_POST['street_no'], "Form incomplete. Please enter your address where you currently reside. This helps us when scheduling positions and meetings.");
  58. $city = check_input($_POST['city'], "Form incomplete. Please enter your city.");
  59. $state = check_input($_POST['state'], "Form incomplete. Please enter your state.");
  60. $zip = check_input($_POST['zip'], "Form incomplete. Please enter your zipcode.");
  61. $shirt = check_input($_POST['shirt'], "Form incomplete. Please enter your t-shirt size.");
  62. ?>
  63.  
  64. <body>
  65.  
  66. <div id="holding">
  67. <span class="choice bigboldfont" style="font-size:22px">
  68.  
  69. <p>Thank you <?php echo $_POST['agreeName'];?>! Your application to volunteer at the Free Press Summer Fest 2012 is being processed.</p>
  70.  
  71. <p>We will send you more information soon to your email address at <span class="font_orange"><?php echo $_POST['email'];?></span></p>
  72.  
  73. </span>
  74.  
  75. </div>
  76. </div></div>
  77. </div>
  78. </div>
  79. </div>
  80.  
  81.  
  82.  
  83. </body>
  84. </html>
  85. <?php
  86.  
  87. if ($problem && strlen($data) == 0)
  88. {
  89. show_error($problem);
  90. }
  91. return $data;
  92.  
  93. function show_error($myError)
  94. {
  95.  
  96.  
  97. ?>
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104. <div id="holding2">
  105. <span class="error_text">
  106. <b><i>Please correct the following error:</i></b><br /><br />
  107. <?php echo $emailError; ?>
  108. <?php echo $myError; ?></span><br /><br />
  109. <a style="#fe1e2d" href="#" onclick="history.go(-1);return false;"><span class="error_text2 font_orange">Click back on your browser or here to return to form</span></a>
  110. </div>
  111.  
  112. <?php
  113. exit();
  114. }
  115. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement