0byt3m1n1
Path:
C:
/
wamp64
/
www
/
Crops
/
[
Home
]
File: user-login.php
<!DOCTYPE html> <html> <head> <title>User Login</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; } .container { width: 300px; margin: 0 auto; padding: 20px; background-color: #ffffff; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } h1 { text-align: center; color: #333333; } form { margin-top: 20px; } label { display: block; margin-bottom: 5px; color: #333333; } input[type="text"], input[type="password"], input[type="email"] { width: 100%; padding: 10px; border: 1px solid #cccccc; border-radius: 3px; } input[type="submit"] { width: 100%; padding: 10px; background-color: #007bff; color: #ffffff; border: none; border-radius: 3px; cursor: pointer; } input[type="submit"]:hover { background-color: #0056b3; } p { text-align: center; margin-top: 10px; } a { color: #007bff; text-decoration: none; } </style> </head> <body> <div class="container"> <!-- User Login Form --> <h1>User Login</h1> <form method="POST" action="#"> <label for="username">Username:</label> <input type="text" id="username" name="username" required> <label for="email">Email:</label> <input type="email" id="email" name="email" required> <label for="password">Password:</label> <input type="password" id="password" name="password" required> <input type="submit" value="Login" name="login"> </form> <p>Not registered yet? <a href="reg.php">Click here</a> to register.</p> <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "crops"; $conn = new mysqli($servername, $username, $password, $dbname); session_start(); $_SESSION['message'] = "Please enter the correct username and password"; if (isset($_POST['login'])) { if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email'])) { header("location: login.php?Empty=Please fill the form"); } else { $user = $_POST['username']; $pass = $_POST['password']; $email = $_POST['email']; $query = "SELECT * FROM registration WHERE Username='$user' AND password='$pass'"; $result = mysqli_query($conn, $query); if (mysqli_fetch_assoc($result)) { $_SESSION['username'] = $_POST['username']; $_SESSION['email'] = $_POST['email']; header("location: sample.php?email=" . $email. "&username=" . $user); } else { echo '<p align="center"><b><font color="red">' . $_SESSION['message'] . '</font></b></p>'; unset($_SESSION['message']); } } } ?> </div> </body> </html>