Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 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. //insert data into database
  33. $sql="INSERT INTO temp SET code='$confirm_code', username='$name', '$email', '$pass'";
  34.  
  35. if($result)
  36. {
  37. $message="Your Confirmation link \r\n";
  38. $message="Click on this link to activate your account \r\n";
  39. $message="localhost/confirmation.php?passkey=$confirm_code";//dont forget!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  40. $sentmail=mail("$email",'Registration Confirmation',"$message",'From: admin@localhost');
  41. header("Location:thankyou.html");
  42. }
  43. else
  44. {
  45. echo "Not found your email in our database";
  46. }
  47.  
  48. //if your email succesfully sent
  49. if($sentmail)
  50. {
  51. echo "Your Confirmation link has been sent to your e-mail account";
  52. }
  53. else
  54. {
  55. echo "cannot send confirmation link to your e-mail adress";
  56. }
  57. }
  58. else
  59. {
  60. header("location:badmatch.html");
  61. }
  62. }
  63. else
  64. {
  65. header("Location:emailinuse.html");
  66. }
  67. }
  68. else
  69. {
  70. header("Location:nameinuse.html");
  71. }
  72. }
  73.  
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement