-
Notifications
You must be signed in to change notification settings - Fork 3
/
validate.php
42 lines (36 loc) · 955 Bytes
/
validate.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
37
38
39
40
41
42
<?php
session_start();
include 'connection.php';
$username=$_REQUEST['login'];
$password=$_REQUEST['password'];
if(!(empty($username) || empty($password)))
{
$q="Select * from users where name='$username' && password='$password';";
$result=mysqli_query($conn,$q);
$stat=mysqli_fetch_array($result);
$rowcount=mysqli_num_rows($result);
if($rowcount>0)
{
$s=$stat['status'];
$s=$s+1;
mysqli_query($conn,"update users set status='$s' where name='$username';");
$_SESSION['username']=$username;
$_SESSION['invalid']="";
$uname=$_SESSION['username'] ;
date_default_timezone_set('Asia/Kolkata');
$current_date = date('Y-m-d H:i:s');
$q="Update users set online=1 ,date_time='$current_date' where name='$uname'; ";
mysqli_query($conn,$q);
header('location:message.php');
}
else
{
$_SESSION['invalid']="wrong username or password";
header("location:sign_login.php");
}
}
else{
$_SESSION['invalid']="empty";
header('LOCATION:index.php');
}
?>