Advertisement
umasoodch

registerationphp

Dec 19th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include('database_1.php');
  4. if(isset($_POST['submit']))
  5. {
  6. if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $_POST['email']))
  7. {
  8. $email= $_POST['email'];
  9. $sql1 = "SELECT * FROM users WHERE email = '$email'";
  10. $result1 = mysqli_query($mysqli,$sql1) or die(mysqli_error());
  11. if (mysqli_num_rows($result1) > 0)
  12. {
  13. echo "This email has already been used";
  14. }
  15.  
  16. elseif($_POST['username'])
  17. {
  18. $username= $_POST['username'];
  19. $sql2 = "SELECT * FROM users WHERE username = '$username'";
  20. $result2 = mysqli_query($mysqli,$sql2) or die(mysqli_error());
  21. if (mysqli_num_rows($result2) > 0)
  22. {
  23. echo "This username has already been used";
  24. }
  25.  
  26. else
  27. {
  28. $username = $_POST['username'];
  29. $email = $_POST['email'];
  30. $passwords = $_POST['password'];
  31. $password = md5($passwords);
  32. $activation = md5(uniqid(rand()));
  33. $sql3 = "INSERT INTO users (username, email, password, activation) VALUES ('$username', '$email', '$password', '$activation')";
  34. $result3 = mysqli_query($mysqli,$sql3) or die('Error: ' . mysqli_error($mysqli));
  35. mkdir("FilesUploading/$username");
  36.  
  37.  
  38.  
  39. if($result3)
  40. {
  41.  
  42. $to = $email;
  43. $subject = "Confirmation from CloudStockpile to $username";
  44. $header = "CloudStockpile: Confirmation from CloudStockpile";
  45. $message = "http://www.cloudstockpile.hostoi.com/Confirm.php?passkey=$activation";
  46.  
  47. $sentmail = mail($to,$subject,$message,$header);
  48.  
  49. if($sentmail)
  50. {
  51. echo "<b/>Hello: $username";
  52. echo "<br/> Your email is: $email";
  53. echo "<br/>Please copy and paste the link below in your browser to activate your account";
  54. echo "<br/> $message ";
  55. echo '<br /><a href="index.html">Return to Cloudstockpile login page</a>';
  56. }
  57. else
  58. {
  59. echo "Cannot send Confirmation link to your e-mail address";
  60. }
  61. }
  62. }
  63. }
  64. }
  65. }
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement