Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.31 KB | None | 0 0
  1. <?php
  2.     session_start();   
  3.  
  4.     $host = "localhost";
  5.     $user = "root";
  6.     $pass = "";
  7.     $db = "jobx";
  8.  
  9. if ($_POST['email'] !== "") {
  10.  
  11.         $email = $_POST['email'];
  12.         $password = $_POST['password'];
  13.  
  14.         $link = mysqli_connect($host, $user, $pass, $db);
  15.  
  16.  
  17.         // STUDENTS'/ REGISTRARS' DETAILS
  18.         $query1 = "SELECT * FROM xuser, xrole WHERE xuser.role_id = xrole.role_id AND email = '$email' AND password = SHA1('$password') ";
  19.         $result1 = mysqli_query($link, $query1) or die(mysqli_error($link));
  20.         $row1 = mysqli_fetch_array($result1);
  21.  
  22.         $_SESSION['name'] = $row1['name'];
  23.         $_SESSION['email'] = $row1['email'];
  24.         $_SESSION['roleId'] = $row1['xuser.roles_id'];
  25. }
  26.  
  27.  
  28.    
  29. ?>
  30.  
  31. <html>
  32. <head>
  33. <title>member Log-in</title>
  34. </head>
  35.  
  36. <body>
  37. <center>
  38. <?php
  39. if (empty($_SESSION['name'])) {
  40.    
  41. ?>
  42.    
  43. <form action = 'login.php' method='POST'>
  44. <table border="0" background = "white.png" width= 800 height= 600>
  45. <tr>
  46. <td>
  47. <center>
  48. <center>Email <input type = 'text' name = 'email'><br>
  49. <center>Password <input type = 'password' name = 'password'><br><br>
  50. <center><input type = submit value = "Log In"><br>
  51. <center><a href='index.html'>Back to Home</a><br>
  52. </form>
  53.  
  54. <?php
  55. }
  56. else {
  57.  
  58.         //member role
  59.         if($_SESSION['rowId'] == 2){
  60.             echo "<font color='black'>";
  61.             echo "<p>You have successfully logged in as <b>".$role."</b>, <b>".$_SESSION['name']." (".$_SESSION['email'].")</b><p>";
  62.             echo "Your Graduation session details are as the followings:";
  63.             echo "<table border='3' cellpadding='3'>";
  64.             echo "<tr>";
  65.             echo "<td><b>Student ID:</b></td> <td><b>Name:</b></td> <td><b>School (Diploma):</b></td> <td><b>Session ID:</b></td>";
  66.             echo "<td><b>Venue:</b></td> <td><b>Date:</b></td> <td><b>Time:</b></td>";
  67.             echo "</tr>";
  68.             echo "Click here to <a href='rsvp.php'>RSVP</a> now. </font>";
  69.             echo $msg ;
  70.         }
  71.  
  72.         //admin role
  73.         else if($_SESSION['rowId'] == 3){
  74.                 echo "<font color='black'>";
  75.             echo "<p>You have successfully logged in as <b>".$role."</b>, <b>(".$_SESSION['email'].")</b>
  76.             <p>Click here to go to <a href = 'admin.html'>Admin </a> Page.</font>";
  77.             echo $msg;
  78.         }
  79.  
  80.         else{
  81.                 echo "<font color='black'>";
  82.             echo "<p>You have entered an invaild username or password.<p>";
  83.             echo "Login <a href ='login.html'>here</a></font> ";
  84.             echo $msg;
  85.         }
  86.  
  87.     }
  88.  
  89.  
  90.  
  91. ?>
  92.  
  93. </body>
  94.  
  95. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement