Guest User

Untitled

a guest
Jul 17th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <?PHP
  2.  
  3. $hostname = "localhost";
  4. $db_user = "username";
  5. $db_password = "passwd";
  6. $database = "databse";
  7. $db_table = "voter_info";
  8.  
  9. $db = mysql_connect($hostname, $db_user, $db_password);
  10. mysql_select_db($database,$db);
  11.  
  12.  
  13. function check_email($email, $optional)
  14. {
  15. if ( (strlen($email) == 0) && ($optional === true) ) {
  16. return true;
  17. } elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
  18. return true;
  19. } else {
  20. return false;
  21. }
  22. }
  23.  
  24. if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  25. $ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
  26. } else {
  27. $ClientIP = $_SERVER['REMOTE_ADDR'];
  28. }
  29.  
  30. $name = $_POST['voter-name'];
  31. $email = $_POST['voter-email'];
  32. $county = $_POST['voter-county'];
  33. $why = $_POST['voter-why'];
  34.  
  35. // validate email using fn above
  36. // validate other form fields, and echo error if validations fail
  37.  
  38. if (get_magic_quotes_gpc) {
  39. $name = stripslashes($name);
  40. $email = stripslashes($email);
  41. $county = stripslashes($county);
  42. $why = stripslashes($why);
  43. }
  44.  
  45.  
  46. $sql = "INSERT INTO $db_table(voter_name,voter_email, voter_county, voter_why) values ('".mysql_real_escape_string($name)."','".mysql_real_escape_string($email)."','".mysql_real_escape_string($county)."','".mysql_real_escape_string($why)."';
  47.  
  48. ?>
Add Comment
Please, Sign In to add comment