-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathredirect.php
More file actions
42 lines (42 loc) · 912 Bytes
/
redirect.php
File metadata and controls
42 lines (42 loc) · 912 Bytes
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
<html>
</body>
<?php
session_start();
$_SESSION['username']="";
$username=$_POST['username'];
$pwd=$_POST['pwd'];
$link= mysqli_connect("localhost","root","","vtwa");
if(!$link)
{
die("Database did not connect. ".mysqli_error($link));
}
$query="select pwd from users where username='$username';";
$results=mysqli_query($link,$query);
$pwd0='';
$found=0;
while($result_array=mysqli_fetch_assoc($results))
{
$pwd0=$result_array['pwd'];
if(strcmp($pwd,$pwd0)==0)
{
$found=1;
}
}
if($found==0)
{
unset($_SESSION['username']);
echo "<script>alert('Incorrect username or password');
window.location.replace('home.php');
</script>";
//window.location.replace('home.php');
}
else
{
$_SESSION['username']=$username;
echo "<script>alert('Successful login');
window.location.replace('home.php');
</script>";
}
?>
</body>
</html>