Advertisement
Guest User

Untitled

a guest
Apr 1st, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. <html>
  2. <head><title>USER AUTHENTICATION</title></head>
  3. <body><body background=img24.jpg>
  4. <body text=black></body>
  5. </html>
  6.  
  7. <?php
  8.  
  9.  
  10. //-----------------checks------------------------
  11. $email = $_POST['email'];
  12. $uid = $_POST['userid'];
  13. $psw = $_POST['psw'];
  14. $repsw = $_POST['psw_re'];
  15. $firstname = $_POST['firstname'];
  16. $lastname = $_POST['lastname'];
  17. $am = $_POST['am'];
  18. $phone = $_POST['phone'];
  19. $sem = $_POST['sem'];
  20.  
  21. $shauser = sha1($uid);
  22. $shapass = sha1($psw);
  23.  
  24. if(userid_validation($uid,5,12)){
  25. if(name_validation($firstname,5,12)){
  26. if(lname_validation($lastname,5,12)){
  27. if(passid_validation($psw,7,12)){
  28. if(repassid_validation($psw,$repsw)){
  29. //<meta http-equiv='refresh' content='0; url=index.php'>;
  30. // if(filter_var($email, $FILTER_VALIDATE_EMAIL)){
  31. // }
  32. $con = mysqli_connect('localhost','root');
  33. if (!$con) { die('Could not connect ERROR: ' . mysqli_error()); }
  34. mysqli_select_db($con,"project_awt");
  35.  
  36. $insert_query="INSERT INTO student (username,password,am,name,surname,semester,telephone,email)VALUES
  37. ('".$shauser."','".$shapass."','".$am."','".$firstname."','".$lastname."','".$sem."','".$phone."','".$email."')";
  38. $select_data= mysqli_query($con,$insert_query);
  39.  
  40. $check_validation="SELECT username,password,am,name,surname,semester,telephone,email
  41. FROM student
  42. WHERE username='".$shauser."' AND password='".$shapass."'";
  43.  
  44. $select_data= mysqli_query($con,$check_validation);
  45. while ($row = mysqli_fetch_array($select_data)){
  46. echo "1) am:".$row['am']."<br>";
  47. echo "2) name:".$row['name']."<br>";
  48. echo "3) surname:".$row['surname']."<br>";
  49. echo "4) semester:".$row['semester']."<br>";
  50. echo "5) tel:".$row['telephone']."<br>";
  51. echo "6) email:".$row['email']."<br>";
  52. echo "7) usn:".$uid."<br>";
  53. echo "8) pwd:".$psw."<br>";
  54. }
  55.  
  56. mysqli_close($con);
  57. echo "<meta http-equiv='refresh' content='0; url=index.html'>";
  58. }
  59. }
  60. }
  61. }
  62. }
  63. return false;
  64.  
  65. function repassid_validation($psw,$repsw){
  66. if($repsw != $psw){
  67. echo "<br>Password and re_password is not the same!!";
  68. return false;
  69. }else if($repsw == $psw){
  70. return true;
  71. }
  72. }
  73.  
  74. function passid_validation($psw,$mx,$my){
  75. if (strlen($psw) == 0 || strlen($psw) >= $my || strlen($psw) < $mx){
  76. echo "<br> Password should not be empty / length be between $mx to $my";
  77. return false;
  78. }
  79. return true;
  80. }
  81.  
  82. function lname_validation($uid,$mx,$my){
  83. if (strlen($uid) == 0 || strlen($uid) >= $my || strlen($uid) < $mx){
  84. echo "<br> User lastname should not be empty / length be between $mx to $my";
  85. return false;
  86. }
  87. return true;
  88. }
  89.  
  90. function userid_validation($uid,$mx,$my){
  91. if (strlen($uid) == 0 || strlen($uid) >= $my || strlen($uid) < $mx){
  92. echo "<br> User Id should not be empty / length be between $mx to $my";
  93. return false;
  94. }
  95. return true;
  96. }
  97.  
  98. function name_validation($uid,$mx,$my){
  99.  
  100. if (strlen($uid) == 0 || strlen($uid) >= $my || strlen($uid) < $mx){
  101. echo "<br> User Name should not be empty / length be between $mx to $my";
  102. return false;
  103. }
  104. return true;
  105. }
  106.  
  107.  
  108. if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
  109. echo "<br> mail ok";
  110. return true;
  111. }
  112. else{
  113. echo "<br> mail not ok";
  114. return false;
  115. }
  116.  
  117.  
  118. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement