-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.php
40 lines (31 loc) · 882 Bytes
/
index2.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
<?php
$include 'dbinfo.php';
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$myusername = $conn -> real_escape_string($_POST['username']);
$mypassword = $conn -> real_escape_string($_POST['password']);
$sql = "SELECT username, password FROM login_details WHERE username = '$myusername' AND password = '$mypassword'";
if($result = $conn -> query($sql))
{
if(mysqli_num_rows($result)==1)
{
$ipaddress = $_SERVER['REMOTE_ADDR'];
$sql2 = "INSERT INTO logins(username, ip_address) VALUES ('$myusername', '$ipaddress')";
if($conn->query($sql2))
{
session_start();
$_SESSION['username'] = $myusername;
header('Location: homePage.php');
}
else
{
echo "There has been an error logging you in";
}
}
}
else
{
echo "wrong username or password";
}
}
?>