-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.php
47 lines (36 loc) · 1.27 KB
/
check.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
43
44
45
46
47
<?php
session_start();
if(isset($_POST['uname'],$_POST['pwd']))
{
$uname = $_POST['uname'];
$pwd = $_POST['pwd'];
$conn = mysqli_connect('localhost','root','','crosscode');
$query = "SELECT * FROM `users` WHERE `uname`='".mysqli_real_escape_String($conn,$uname)."'AND `pwd`='".mysqli_real_escape_String($conn,$pwd)."'" ;
$result=mysqli_query($conn,$query);
if (mysqli_num_rows($result)) {
while($row=mysqli_fetch_assoc($result))
{
$attempt=$row['attempt'];
}
if($attempt == 0)
{
$usql = "UPDATE `users` SET `attempt`='1' WHERE `uname`='".mysqli_real_escape_String($conn,$uname)."'";
mysqli_query($conn,$usql);
$_SESSION['id']=$uname;
mysqli_close($conn);
header("Location:crossword.php");
}
else
{
header("Location:index.php");
}
}
}
else
{
echo "<script>
alert('Wrong username or password');
window.location.href='index.php';
</script>";
}
?>