-
Notifications
You must be signed in to change notification settings - Fork 0
/
login2.php
44 lines (35 loc) · 1.16 KB
/
login2.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
<?php
$servername = "localhost"; // Replace with your server name
$username = "root"; // Replace with your database username
$dbname = "use"; // Replace with your database name
// Get input from form
$user = $_POST['username'];
$email = $_POST['email'];
$pass = $_POST['password'];
try {
// Create a new PDO connection
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, '');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Prepare SQL statement
$stmt = $conn->prepare("SELECT * FROM last WHERE username = :username AND email = :email AND password = :password");
// Bind parameters
$stmt->bindParam(':username', $user);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':password', $pass);
// Execute the query
$stmt->execute();
// Check if the user exists
if($stmt->rowCount() > 0) {
// Redirect to another page after successful login
header("Location: ./submit.html");
exit();
} else {
header("Location: ./login2.php");
}
}
catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
// Close connection
$conn = null;
?>