Advertisement
Guest User

Untitled

a guest
Sep 16th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. <?php
  2. if (!isset($_POST['submit']))
  3. {
  4. echo "<form action=\"register.php\" method=\"POST\">";
  5. echo "<table>";
  6. echo "<tr>";
  7. echo "<td width=\"40%\">שם משתמש :</td><td width=\"60%\"><input name=\"username\" size=\"20\" type=\"text\" />";
  8. echo "</tr>";
  9. echo "<tr>";
  10. echo "<td width=\"40%\">סיסמה :</td><td width=\"60%\"><input name=\"password\" size=\"20\" type=\"password\" />";
  11. echo "</tr>";
  12. echo "<tr>";
  13. echo "<td width=\"40%\">אמת סיסמה :</td><td width=\"60%\"><input name=\"password_check\" size=\"20\" type=\"password\" />";
  14. echo "</tr>";
  15. echo "<tr>";
  16. echo "<td width=\"40%\">דואר אלקטרוני :</td><td width=\"60%\"><input name=\"email\" size=\"20\" type=\"text\" />";
  17. echo "</tr>";
  18. echo "<tr height=\"8\"></tr><tr>";
  19. echo "<td colspan=\"2\" align=\"left\"><input type=\"submit\" name=\"submit\" value=\"שלח\"</td>";
  20. echo "</tr>";
  21. echo "</table>";
  22. echo "</form>";
  23. }
  24. else
  25. {
  26. if(!ctype_alnum($_POST['username']))
  27. exit("שם המשתמש יכול להכיל אותיות וספרות בלבד.");
  28. if(strlen($_POST['user_name']) > 30)
  29. exit("שם המשתמש לא יהיה ארוך מ-20 תווים");
  30. else
  31. $username = form($_POST['username']);
  32.  
  33. if ($_POST['password'] != $_POST['password_check'])
  34. exit("הסיסמאות שהקשת אינם זהות.");
  35. else
  36. $password = md5($_POST['password']);
  37.  
  38. $email = form($_POST['email']);
  39.  
  40. if (($username == "") || ($password == "") || ($email == ""))
  41. exit("לא מולאו כל הפרטים.");
  42.  
  43. if ($password != $password_check)
  44. exit("הסיסמאות שהקשת אינם זהות.");
  45.  
  46. $q = $db->prepare("SELECT * FROM `users` WHERE username = ?");
  47. $q->execute(array($username));
  48. $r = $q->rowCount();
  49.  
  50. if ($r > 0)
  51. exit("שם המשתמש כבר קיים במערכת, אנא בחר בשם משתמש אחר.");
  52. else
  53. {
  54. $q = $db->prepare("INSERT INTO `users` (username,password,email) VALUES (?,?,?)");
  55. $q->execute(array($username, $password, $email));
  56. header("Location: register.php"); // Back to login.
  57. }
  58. }
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement