Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3.  
  4. session_start();
  5.  
  6.  
  7.  
  8.     $host="localhost";
  9.     $username="root";
  10.     $password="alexi";
  11.     $db_name="users";
  12.     $tbl_name="accounts";
  13.  
  14. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  15. mysql_select_db("$db_name") or die("cannot select DB");
  16.  
  17. $username=$_POST['username'];
  18. $password=$_POST['password'];
  19.  
  20. $sql="SELECT * FROM `accounts` WHERE `username`='".$username."' and `password`='".$password."'";
  21.  
  22. $result=mysql_query($sql) or die ( mysql_error () );
  23.  
  24.  
  25. $count=mysql_num_rows($result);
  26.  
  27. if($count==1){
  28.  
  29. $_SESSION['username'] = $username;
  30.  
  31. if(isset($_SESSION['username'])) { echo 'You are logged in'; }
  32.  
  33. else {
  34.  
  35. echo 'incorrect'; }
  36. }
  37.  
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement