Guest User

Untitled

a guest
Jan 19th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. include("../database/db_conection.php");
  2. if(isset($_POST['register']))
  3. {
  4. $user_name=$_POST['name'];
  5. $user_lastname=$_POST['lastname'];
  6. $user_email=$_POST['email'];
  7. $user_position=$_POST['position'];
  8. $user_country=$_POST['country'];
  9. $user_pass=$_POST['pass'];
  10. $user_copass=$_POST['copass'];
  11. $salt="h4T3hd9Fse";
  12.  
  13. if($user_name=='')
  14. {
  15. //javascript use for input checking
  16. echo"<script>alert('Please enter the name')</script>";
  17. exit();//this use if first is not work then other will not show
  18. }
  19.  
  20. if($user_position=='')
  21. {
  22. echo"<script>alert('Please enter the position')</script>";
  23. exit();
  24. }
  25.  
  26. if($user_country=='')
  27. {
  28. echo"<script>alert('Please enter the country')</script>";
  29. exit();
  30. }
  31.  
  32. if($user_pass=='')
  33. {
  34. echo"<script>alert('Please enter the password')</script>";
  35. exit();
  36. }
  37.  
  38. if ($user_pass != $user_copass)
  39. {
  40. echo"<script>alert('Error... Passwords do not match')</script>";
  41. exit();
  42. }else{
  43. $user_pass=md5($salt.$user_pass);
  44. $user_copass=md5($salt.$user_copass);
  45. }
  46.  
  47. if(!filter_var($user_email, FILTER_VALIDATE_EMAIL)){
  48. echo"<script>alert('Please enter the email')</script>";
  49. exit();
  50. }
  51. //here query check weather if user already registered so can't register again.
  52. $check_email_query="select * from users WHERE user_email='$user_email'";
  53. $run_query=mysqli_query($dbcon,$check_email_query);
  54.  
  55. if(mysqli_num_rows($run_query)>0)
  56. {
  57. echo "<script>alert('Email $user_email is already exist in our database, Please try another one!')</script>";
  58. exit();
  59. }
  60. //insert the user into the database.
  61. $insert_user="insert into users (user_name,user_pass,user_email,user_lastname,user_position,user_country,user_copass) VALUE ('$user_name','$user_pass','$user_email','$user_lastname','$user_position','$user_country','$user_copass')";
  62. if(mysqli_query($dbcon,$insert_user))
  63. {
  64. echo"<script>window.open('../../index.php','_self')</script>";
  65. }
  66.  
  67. }
  68.  
  69. session_start();//session starts here
  70.  
  71. include("database/db_conection.php");
  72.  
  73. if(isset($_POST['login']))
  74. {
  75. $user_email=$_POST['email'];
  76. $user_pass=$_POST['pass'];
  77.  
  78. $check_user="select * from users WHERE user_email='$user_email'AND user_pass='$user_pass'";
  79.  
  80. $run=mysqli_query($dbcon,$check_user);
  81.  
  82. if(mysqli_num_rows($run))
  83. {
  84. echo "<script>window.open('welcome.php','_self')</script>";
  85.  
  86. $_SESSION['email']=$user_email;//here session is used and value of $user_email store in $_SESSION.
  87.  
  88. }
  89. else
  90. {
  91. echo "<script>alert('Email or password is incorrect!')</script>";
  92. }
  93. }
Add Comment
Please, Sign In to add comment