Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. <?php
  2. include('confff.php');
  3. //test to see if username is alfanumeric
  4. $testname=$_POST['username'];
  5. if (!eregi("([^A-Za-z0-9])",$testname))
  6. {
  7. //test for duplicate names
  8. $query="SELECT * FROM game WHERE username ='$_POST(username)'";
  9. $result=mysql_query($query);
  10. $num=mysql_num_rows($result);
  11.  
  12. if ($num == 0)
  13. {
  14. //test for duplicate email
  15. $query2="SELECT * FROM game WHERE email = '$_POST(email)'";
  16. $result2=mysql_query($query2);
  17. $num2 = mysql_num_rows($result2);
  18.  
  19. if($num2==0)
  20. {
  21. //if emails and passwords match up
  22. if(($_POST['pass']==$_POST['pass2']).($_POST['email']==$_POST['email2']))
  23. {
  24. //generate random confirmation code
  25. $confirmation_code=md5(uniqid(rand()));
  26.  
  27. //get rid of all html from hackers
  28. $name=strip_tags($_POST['username']);
  29. $email=strip_tags($_POST['email']);
  30. $pass=strip_tags($_POST['pass']);
  31.  
  32. $sql="INSERT INTO temp (code, username, email, password) VALUES ('$confirmation_code', '$testname', '$email', '$pass')";
  33. if (!mysql_query($sql,$con)) // <--- REPLACE "CON" WITH THE VARIALBE YOU CHOSE TO HOLD YOUR CONNECTION (it's in your confff.php file)
  34. {
  35. die('Error: ' . mysql_error());
  36. }
  37. if($result)
  38. {
  39. $message="Your Confirmation link \r\n";
  40. $message="Click on this link to activate your account \r\n";
  41. $message="localhost/confirmation.php?passkey=$confirmation_code";//dont forget!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  42. $sentmail=mail("$email",'Registration Confirmation',"$message",'From: admin@localhost');
  43. header("Location:thankyou.html");
  44. }
  45. else
  46. {
  47. echo "Not found your email in our database";
  48. }
  49.  
  50. //if your email succesfully sent
  51. if($sentmail)
  52. {
  53. echo "Your Confirmation link has been sent to your e-mail account";
  54. }
  55. else
  56. {
  57. echo "cannot send confirmation link to your e-mail adress";
  58. }
  59. }
  60. else
  61. {
  62. header("location:badmatch.html");
  63. }
  64. }
  65. else
  66. {
  67. header("Location:emailinuse.html");
  68. }
  69. }
  70. else
  71. {
  72. header("Location:nameinuse.html");
  73. }
  74. }
  75.  
  76. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement