Advertisement
Guest User

Untitled

a guest
Jul 10th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 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 users 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 users 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.  
  25.  
  26. //generate random confirmation code
  27. $confirmation_code=md5(uniqid(rand()));
  28.  
  29. //get rid of all html from hackers
  30. $name=strip_tags($_POST['username']);
  31. $email=strip_tags($_POST['email']);
  32. $pass=strip_tags($_POST['[pass']);
  33.  
  34. //insert data into database
  35. $sql="INSERT INTO temp SET code='$confirm_code', username='$name', '$email', '$pass'";
  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=$confirm_code";//dont forget!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  42.  
  43. $sentmail=mail("$email",'Registration Confirmation',"$message",'From: admin@localhost');
  44. header("Location:thankyou.html");
  45. }
  46. else {
  47. echo "Not found your email in our database";
  48. }
  49.  
  50. //if your email succesfully sent
  51. if($sentmail){
  52. echo "Your Confirmation link has been sent to your e-mail account";
  53. }
  54. else {
  55. echo "cannot send confirmation link to your e-mail adress";
  56. }
  57. }
  58. }
  59. else
  60. {
  61. header("location:badmatch.html");
  62. }
  63. }
  64. else
  65. {
  66. header("Location:emailinuse.html");
  67. }
  68. else
  69. {
  70. header("Location:nameinuse.html");
  71. }
  72.  
  73.  
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement