-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfad.php
More file actions
36 lines (31 loc) · 1.07 KB
/
Copy pathfad.php
File metadata and controls
36 lines (31 loc) · 1.07 KB
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
<?php
// Establish database connection
$conn = new mysqli("localhost", "root", "", "nexpertise");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve username and password from form
$username = $_POST['username1'];
$password = $_POST['password2'];
// SQL query to fetch admin details based on username and password
$sql = "SELECT * FROM admintb WHERE username = '$username' AND password = '$password'";
$result = $conn->query($sql);
if ($result->num_rows == 1) {
// Admin credentials are correct, redirect to add.php
header("Location: ad.php");
exit();
} else {
// Admin credentials are incorrect, redirect back to signup.php with error message
header("Location: signup.php?error=Invalid credentials");
exit();
}
} else {
// If the request method is not POST, redirect back to signup.php
header("Location: signup.php");
exit();
}
// Close database connection
$conn->close();
?>