Advertisement
Guest User

Untitled

a guest
Nov 10th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. <?php
  2. $host="localhost";
  3. $dbuser="root";
  4. $pass="";
  5. $dbname="online_exam";
  6. $conn=mysqli_connect($host,$dbuser,$pass,$dbname);
  7. // echo "$conn";
  8. if(mysqli_connect_errno())
  9. {die("connection Failed!".mysqli_connect_error());
  10. }
  11. ?>
  12. <html>
  13. <body background="bg/hero8.jpg" text="white">
  14. <table cellspacing="15px" border="0px" align="center">
  15. <tr></tr>
  16. <tr></tr>
  17. <tr></tr>
  18. <tr></tr>
  19. <tr></tr>
  20. <tr></tr>
  21. <tr></tr>
  22. <tr></tr>
  23. <tr></tr>
  24. <tr></tr>
  25. <tr></tr>
  26. <tr></tr>
  27. <tr></tr>
  28. <tr></tr>
  29.  
  30. <form action="loginS.php" method="POST">
  31. <tr>
  32. <td>STUDENTS LOGIN</td></tr>
  33. <tr>
  34. <td>Enter the user name:<input type="text" name="uname"></td></tr>
  35. <tr>
  36. <td>Enter the Password:<input type="password" name="pwd"></td></tr>
  37. <tr><td><input type="submit" name="submit" value="LOGIN"></td></tr>
  38.  
  39. </table>
  40. </body>
  41. </html>
  42. <?php
  43. if(isset($_POST['submit'])){
  44. $uname = $_POST['uname'];
  45. $pswd=$_POST['pwd'];
  46.  
  47. if(empty($uname) || empty($pswd))
  48. {echo"OOPs! Your are suppose to not leave any of the constrains empty ";}
  49. else{
  50. $sql="SELECT * FROM student WHERE Email='{$uname}'AND Pass='{$pswd}';"; //Q_no, Ques, Op_1, Op_2, Op_3, Op_4, Ans
  51. $res=mysqli_query($conn,$sql);
  52. if(!$res){
  53. //die("query failed".mysqli_error($conn));
  54. echo "User name or password is wrong";
  55.  
  56. }
  57. else{$flag=0;
  58. while($row=mysqli_fetch_array($res)){
  59.  
  60. //$course = $row['Course']; //$question_array[$i]=$row['Ques'];
  61. $name = $row['Name'];
  62. $lastresult= $row['Lastresult'];
  63. $USN=$row['USN'];
  64. $flag=1;
  65.  
  66. }
  67. if($flag==0)
  68. {echo "Wrong Password or Username";
  69. exit;}
  70. session_start();
  71. $_SESSION['myValue']=$lastresult;
  72. $_SESSION['myValue1']=$name;
  73. $_SESSION['myValue2']=$USN;
  74.  
  75. header("Location: Student_menu.php");
  76. exit;
  77. }
  78. }
  79. }
  80.  
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement