Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. include_once('../includes/connection.php');
  5.  
  6. if (isset($_SESSION['logged_in'])) {
  7.     //nnmn
  8. } else {
  9.  
  10.     if (isset($_POST['username'],$_POST['password'])) {   // هنا
  11.         $username = $_POST['username'];
  12.         $password = md5($_POST['password']);
  13.        
  14.         if (empty($username) && empty($password)) {
  15.             $error = "All fields are required!";
  16.             echo $error;
  17.         } else {
  18.             $query = $pdo->prepare("SELECT * FROM editor WHERE Editor_User_Name = ? AND Editor_Password = ? ");
  19.  
  20.             $query->bindValue(1, $username);
  21.             $query->bindValue(2, $password);
  22.  
  23.             $query->exesute();
  24.  
  25.             $num = $query->rowCount();
  26.  
  27.             if ($num == 1) {
  28.                 $_SESSION['logged_in'] = true;
  29.                 header('location: index.php ');
  30.                 exit();
  31.             }else {
  32.                 $error = "Incorrect details!";
  33.             }
  34.         }
  35.     }
  36.  
  37. ?>
  38.  
  39. <?php include_once('../includes/header.php'); ?>
  40.  
  41. <br /><br />
  42.  
  43. <?php if (isset($error)) { ?>
  44.     <small style="color:#aa0000;"><?php echo $error; ?></small>
  45.     <br />
  46. <?php } ?>
  47.  
  48. <form action="index.php" method="post"></form>
  49.     <input type="text" name="username" placeholder="Username" autocomplete="off"/>
  50.     <input type="password" name="password" placeholder="Password" />
  51.     <input input type="submit" value="Login" name="submit" >
  52.     <?php include_once('../includes/footer.php'); ?>
  53.        
  54.  
  55. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement