Advertisement
Guest User

Untitled

a guest
Oct 19th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.34 KB | None | 0 0
  1. <?php
  2.     include_once("connect/connection.php");
  3.     class Logins
  4.     {
  5.         public $connect;
  6.         function __constract()
  7.         {
  8.             $con = new Database;
  9.             $connection=$con->dbConnection();  
  10.             $this->connect=$connection;
  11.         }
  12.         public function filter($username,$password)
  13.         {
  14.             $username = htmlspecialchars($username);
  15.             $username = strip_tags($username);
  16.             $password = htmlspecialchars($password);
  17.             $password = md5($password)."~&(^m";
  18.             $this->check($username,$password);
  19.         }
  20.         public function check($user,$pass)
  21.         {
  22.             $sql = "SELECT * FROM admin WHERE `user` = :user NAD `pass`= :pass";           
  23.             $result = $this->connect->prepare($sql);
  24.             $result->bindParam(":user",$user);
  25.             $result->bindParam(":pass",$pass);
  26.             $result->execute();
  27.             $num=$result->fetchColumn();           
  28.             if($num == 1)
  29.             {
  30.                 $row = $result->fetchAll(PDO::FETCH_ASSOC);
  31.                 $_SESSION["Is_Login"]=$row["name"];
  32.             }else{
  33.                 header("location: ops.php");
  34.                 exit();
  35.             }
  36.         }
  37.     }
  38.     $log = new Logins;
  39.     if(isset($_POST["login"]))
  40.     {
  41.         $log->check($_POST["user"],$_POST["pass"]);
  42.     }
  43. ?>
  44. <!doctype html>
  45. <html>
  46. <head>
  47. <meta charset="utf-8">
  48. <title>Untitled Document</title>
  49. </head>
  50.  
  51. <body>
  52.     <form method="post" action="<?php print_r(htmlspecialchars($_SERVER['PHP_SELF'])); ?>">
  53.         <input type="text" name="user">
  54.         <input type="text" name="pass">    
  55.         <input type="submit" value="login" name="login">
  56.     </form>
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement