<?php
session_start();

if (empty($_SESSION['signup_full_name'])) {
    header("Location: SS_Signup_pg1.php");
    exit();
}

$error = "";

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $email = $_POST['email'];
    $pw    = $_POST['password'];
    $confirm = $_POST['password_confirm'];

    if ($pw !== $confirm) {
        $error = "Passwords do not match.";
    } else {
        $_SESSION['signup_email'] = $email;
        $_SESSION['signup_password'] = $pw;
        header("Location: SS_Signup_pg3.php");
        exit();
    }
}
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sign Up - Smart Spender</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>

  <!-- Logo top-left -->
  <header class="signup-header">
    <div class="brand">
      <span class="logo">&#128178;</span>
      <span class="name"><strong>Smart</strong> <br> 
        <strong>Spender</strong> </span>
    </div>
  </header>

 <!-- Main content -->
  <main class="signup-main container">
    <h1>Create a password with atleast 8 characters, including one uppercase letter, one number, and one special character.</h1>

<?php if ($error) echo "<p style='color:red'>$error</p>"; ?>

<form class="signup-form" action="SS_Signup_pg2.php" method="post">
    <label for="email">Email</label>
        <input class="signup-form" for="email" type="email" name="email" required>
    </label><br>

        <label for="Password">Password</label>
        <input class="signup-form"for="Password" type="password" name="password" required>
    </label><br>

    <label>Confirm Password:
        <input class="signup-form" for="Password" type="password" name="password_confirm" required>
    </label><br>

    <button class="btn" type="submit">Next</button>
</form>
</body>
</html>
