prepare($sql); $stmt->execute([$email]); if ($stmt->fetch()) { header("Location: signup.php?error=Email already exists."); exit(); } $password_hash = password_hash($password, PASSWORD_BCRYPT); $sql = "INSERT INTO users (name, email, password, lat, lng, location_label, location_notes) VALUES (?, ?, ?, ?, ?, ?, ?)"; $stmt = $pdo->prepare($sql); if ($stmt->execute([$name, $email, $password_hash, $lat, $lng, $location_label, $location_notes])) { $user_id = $pdo->lastInsertId(); $_SESSION['user_id'] = $user_id; $_SESSION['user_name'] = $name; header("Location: index.php"); exit; } else { die("Error: Could not execute the query."); } } catch (PDOException $e) { die("Could not connect to the database $dbname :" . $e->getMessage()); } } ?>