samclarko

index.php

Jul 17th, 2016
143
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. include 'connect.php';
  3.  
  4. if(isset($_REQUEST['submit'])){
  5.    
  6.     $username = $_POST['username'];
  7.     $password = $_POST['password'];
  8.    
  9.     if(!empty($username) && !empty($password)){
  10.        
  11.         $sel = "SELECT * FROM members WHERE username = '$username' AND password = '$password'";
  12.        
  13.         $re = mysql_query($sel);
  14.        
  15.         if($re){
  16.        
  17.         $me = mysql_fetch_array($re);
  18.        
  19.             if($me == 0){
  20.                
  21.                 $message= 'Username and Password Incorrect';
  22.                
  23.             }else{
  24.                
  25.                 $_SESSION['username'] = $username;
  26.                
  27.                 header('Location: mainpage.php');
  28.             }
  29.            
  30.     }
  31.        
  32.     }else{
  33.        
  34.         $message= 'All fields are required';
  35.        
  36.     }
  37. }else{
  38.     $message= "";
  39. }
  40.        
  41.  
  42. ?>
  43. <html>
  44. <title>School Stuff</title>
  45. <head>
  46. <link rel="stylesheet" href="css/style.css" type="text/css">
  47.  
  48. </head>
  49.  
  50.  
  51. <body>
  52. <div  id="container">
  53.         <div class="head">
  54.             School Portal
  55.         </div>
  56.                 <div id="sideleft">
  57.                     <div class="sideleft">
  58.                             <ul>
  59.                                     <li><a href="index.php" title="">Home Page</a></li>
  60.                                     <li><a href="reg.php" title="">Register</a></li>
  61.                                    
  62.                            
  63.                             </ul>
  64.                     </div>
  65.                 </div>
  66.                
  67.                 <div id="sideright";>
  68.                     <h4>Login</h4>
  69.                     <form action="index.php" method="post">
  70.                     <font face="Times New Roman, Times, serif" color="#CC0000"><?php echo $message; ?></font>
  71.                         <table>
  72.                             <tr>
  73.                                 <td>Username</td>
  74.                                 <td><input type="text" name="username"></td>
  75.                              </tr>
  76.                              
  77.                              <tr>
  78.                                 <td>Password</td>
  79.                                 <td><input type="password" name="password"></td>
  80.                              </tr>
  81.                              
  82.                              <tr>
  83.                                 <td>&nbsp;</td>
  84.                                 <td><input type="submit" name="submit" value="Login"></td>
  85.                              </tr>
  86.                       </table>
  87.                  </form>
  88.                 </div>
  89. </div>
  90. </body>
  91.  
  92. </html>
Add Comment
Please, Sign In to add comment