-
Notifications
You must be signed in to change notification settings - Fork 6
/
logIn.php
36 lines (33 loc) · 1.11 KB
/
logIn.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
session_start();
if ( isset($_SESSION['uid'])&&isset($_SESSION['pass'])){
$username = $_SESSION['uid'];
$password = $_SESSION['pass'];
require_once 'connect.php';
$sql = "SELECT * FROM `user` WHERE account_id='$username' and password='$password'";
$result = mysql_query($sql) or die(mysql_error());
$count = mysql_num_rows($result);
require_once 'close.php';
if ($count == 1){
echo "You are logged in";
header("location:welcome.php");
}
}
require_once 'connect.php';
if (isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM `user` WHERE account_id='$username' and password='$password'";
$result = mysql_query($sql) or die(mysql_error());
$count = mysql_num_rows($result);
require_once 'close.php';
if ($count == 1){
echo "You are logged in";
$_SESSION['uid']= $username;
$_SESSION['pass']= $password;
header("location:welcome.php");
}else {
echo "<div id = 'failed'> Login Failed </div>";
}
}
?>