-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
28 lines (27 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
<?php
include('dbconfig.php');
session_start();
if(isset($_POST['signin'])){
if (isset($_POST['username'])){
$error="";
$username = mysqli_real_escape_string($db,$_POST['username']);
$password = mysqli_real_escape_string($db,$_POST['password']);
//Checking is user existing in the database or not
$query = "SELECT * FROM `userdata` WHERE username='$username' and password='$password'";
$result = mysqli_query($db,$query);
$row=mysqli_fetch_array($result);
if(mysqli_num_rows($result)==1){
$_SESSION['username'] = $username;
if($row['type']=="farmer"){
header("Location: farmerhome.php");
}
else {
header("Location: homepage.php");
}
}
else{
echo "<script>alert('Invalid login.Please try again');window.location.href='index.html';</script>";
}
}
}
?>