<?php include("../config.php"); ?>

<!DOCTYPE html>
<html>
<head>
<title>Create Account</title>
<link rel="stylesheet" href="style.css">
</head>
<body>

<div class="header">
<h1>Kothamasu Group Inc</h1>
<p>Secure Mortgage Portal</p>
</div>

<div class="container">

<h2>Create Account</h2>

<?php

if ($_SERVER["REQUEST_METHOD"] == "POST") {

$name = $_POST['name'];
$email = $_POST['email'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);

$sql = "INSERT INTO users (name,email,password)
VALUES ('$name','$email','$password')";

if($conn->query($sql)){

echo "<p style='color:green'>Account created successfully</p>";

}else{

echo "<p style='color:red'>Email already exists</p>";

}

}
?>

<form method="POST">

<label>Full Name</label>
<input type="text" name="name" required>

<label>Email Address</label>
<input type="email" name="email" required>

<label>Password</label>
<input type="password" name="password" required>

<button type="submit">Create Account</button>

</form>

<div class="link">
Already have account? <a href="login.php">Login here</a>
</div>

</div>

</body>
</html>
