Advertisement
Guest User

Login

a guest
Jul 3rd, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.  
  4.     $con=mysql_connect('localhost','root','');
  5.  
  6.     if(!$con){
  7.         header('Location: index.php?msg=Αποτυχημένη σύνδεση στη βάση δεδομένων!');
  8.     }
  9.  
  10.     $db=mysql_select_db('usedcars',$con);
  11.  
  12.     if(!$db){
  13.         header('Location: index.php?msg=Αποτυχημένη σύνδεση στη usedcars!');
  14.     }
  15.  
  16.     $username = $_POST['username'];
  17.     $password = $_POST['password'];
  18.        
  19.     $query=mysql("SELECT * FROM `USERS` WHERE `USERNAME`='$username' AND `PASSWORD`='$password'");
  20.     $result=mysql_query($query);
  21.     $count=mysql_num_rows($result);
  22.  
  23.     if($count==1){
  24.         $_SESSION['username']=$username;
  25.         header('Location= logged_in_page.php');
  26.     }
  27.     else{
  28.         header('Location: index.php?msg=Αποτυχημένη σύνδεση! Γραμμές:'.$count.'!!');
  29.     }
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement