-
Notifications
You must be signed in to change notification settings - Fork 0
/
signin.php
35 lines (31 loc) · 906 Bytes
/
signin.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
<?php
include('dbcon.php');
global $pdo;
if(isset($_POST['loguser']) and isset($_POST['logpass']))
{
if(!empty($_POST['loguser']) and !empty($_POST['logpass']))
{
$user = $_POST['loguser'];
$pass = $_POST['logpass'];
$query = $pdo->prepare("select user_id from user where username= ? and password = ?");
$query->bindParam(1,$user);
$query->bindParam(2,$pass);
$query->execute();
if($query->rowCount()>0)
{
$row = $query->fetch(PDO::FETCH_OBJ);
session_start();
$_SESSION['user_id'] = $row->user_id;
?><script>window.location.href = "./index.php";</script><?php
}
else
{
echo '<span style="color:red; padding:2px;">Invalid Username/Password.Try Again.</span>';
}
}
else
{
echo '<span style="color:red; padding:2px;">Please provide both fields.</span>';
}
}
?>