Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. include('connection.php');
  5.  
  6. $missinguser ='<p>please try again username</p>';
  7. $missingemail='<p>please tr again email</p>';
  8. $invalidgemail='<p>bad email</p>';
  9. $missingpasswordr='<p>please try again password</p>';
  10. $invalidpasswordr='<p>bad password</p>';
  11. $differentpasswordr='<p>different password</p>';
  12. $missingpassword2='<p>forget password ?</p>';
  13.  
  14. if(empty($_POST["username"]))
  15. {
  16. $errors .= $missinguser;
  17. }else
  18. {
  19. $username = filter_var($_POST["username"], FILTER_SANITIZE_STRING);
  20. }
  21.  
  22. if(empty($_POST["email"]))
  23. {
  24. echo $errors .=$missingemail;
  25. }else
  26. {
  27. $email = filter_var($_POST["email"], FILTER_SANITIZE_EMAIL);
  28. if(filter_var($email,FILTER_VALIDATE_EMAIL)){
  29. $errors .=$invalidgemail;
  30. }
  31. }
  32.  
  33. if(empty($_POST["password"]))
  34. {
  35. $errors .=$missingpasswordr;
  36. }else if(!(strlen($POST["password"])>6
  37. and preg_match('/[A-Z]/',$_POST["password"])
  38. and preg_match('/[0-9]/',$_POST["password"])
  39. )
  40. ){
  41. $errors .= $invalidpasswordr;
  42. }else{
  43. $password = filter_var($_POST["password2"], FILTER_SANITIZE_STRING);
  44. if(empty($POST["password"])){
  45. $errors .= $missingpassword2;
  46. }else
  47. {
  48. $password2 = filter_var($_POST["password2"], FILTER_SANITIZE_STRING);
  49. if($password!==$password2)
  50. {
  51. $errors .= $differentpasswordr;
  52. }
  53. }
  54. }
  55. if($errors){
  56. $resultmessage = '<div class="alert alert-danger">'.$errors.'</div>';
  57. echo $resultmessage;
  58. }
  59.  
  60. $username = mysqli_real_escape_string($link,$username);
  61. $email = mysqli_real_escape_string($link,$email);
  62. $password = mysqli_real_escape_string($link,$password);
  63. $password2 = mysqli_real_escape_string($link,$password2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement