Guest User

Untitled

a guest
Jul 3rd, 2016
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include('configdb.php');
  4. if(isset($_POST['submit']))
  5. {
  6. //whether the username is blank
  7. if($_POST['username'] == '')
  8. {
  9. $_SESSION['error']['username'] = "User Name is required.";
  10. }
  11. //whether the email is blank
  12. if($_POST['email'] == '')
  13. {
  14. $_SESSION['error']['email'] = "E-mail is required.";
  15. }
  16. else
  17. {
  18. //whether the email format is correct
  19. if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $_POST['email']))
  20. {
  21. //if it has the correct format whether the email has already exist
  22. $email= $_POST['email'];
  23. $sql1 = "SELECT * FROM user WHERE email = '$email'";
  24. $result1 = mysqli_query($mysqli,$sql1) or die(mysqli_error());
  25. if (mysqli_num_rows($result1) > 0)
  26. {
  27. $_SESSION['error']['email'] = "This Email is already used.";
  28. }
  29. }
  30. else
  31. {
  32. //this error will set if the email format is not correct
  33. $_SESSION['error']['email'] = "Your email is not valid.";
  34. }
  35. }
  36. //whether the password is blank
  37. if($_POST['password'] == '')
  38. {
  39. $_SESSION['error']['password'] = "Password is required.";
  40. }
  41. //if the error exist, we will go to registration form
  42. if(isset($_SESSION['error']))
  43. {
  44. header("Location: index.php");
  45. exit;
  46. }
  47. else
  48. {
  49. $username = $_POST['username'];
  50. $email = $_POST['email'];
  51. $password = $_POST['password'];
  52. $com_code = md5(uniqid(rand()));
  53.  
  54. $sql2 = "INSERT INTO user (username, email, password, com_code) VALUES ('$username', '$email', '$password', '$com_code')";
  55. $result2 = mysqli_query($mysqli,$sql2) or die(mysqli_error());
  56.  
  57. if($result2)
  58. {
  59. $to = $email;
  60. $subject = "$username מייל אישור למשתמש :";
  61. $headers = "$email : הכנס ללינק על מנת לאמת את חשבונך";
  62. $headers.= "Content-Type: text/html; charset=UTF-8";
  63. $message = "Please click the link below to verify and activate your account. rn"; $message .= "http://www.nevol.info/email_test/confirm.php?passkey=$com_code";
  64. $sentmail = mail($to,$subject,$message, $headers);
  65.  
  66. if($sentmail)
  67. {
  68. echo "&#1502;&#1497;&#1497;&#1500; &#1492;&#1488;&#1497;&#1513;&#1493;&#1512; &#1504;&#1513;&#1500;&#1495; &#1500;&#1499;&#1514;&#1493;&#1489;&#1514; &#1492;&#1502;&#1497;&#1497;&#1500; &#1513;&#1504;&#1512;&#1513;&#1502;&#1492;";
  69. }
  70. else
  71. {
  72. echo "&#1500;&#1488; &#1492;&#1497;&#1492; &#1504;&#1497;&#1514;&#1503; &#1500;&#1513;&#1500;&#1493;&#1495; &#1502;&#1497;&#1497;&#1500; &#1500;&#1499;&#1514;&#1493;&#1489;&#1514; &#1513;&#1504;&#1512;&#1513;&#1502;&#1492;";
  73. }
  74. }
  75. }
  76. }
  77. ?>
Add Comment
Please, Sign In to add comment