2022-11-02 15:39:55 +00:00
|
|
|
<?php
|
2022-11-20 13:20:58 +00:00
|
|
|
require_once '../../functions.php';
|
|
|
|
|
|
2022-11-02 15:39:55 +00:00
|
|
|
function addUser() {
|
2022-11-20 13:20:58 +00:00
|
|
|
$pdo = startDB();
|
2022-11-02 15:39:55 +00:00
|
|
|
|
2022-11-02 22:36:20 +00:00
|
|
|
$stmt = $pdo->prepare('INSERT INTO users (first_name, last_name, email, password, admin)
|
|
|
|
|
VALUES (:first_name, :last_name, :email, :password, :admin)');
|
2022-11-02 15:39:55 +00:00
|
|
|
$values = [
|
|
|
|
|
'first_name' => $_POST['first_name'],
|
|
|
|
|
'last_name' => $_POST['last_name'],
|
|
|
|
|
'email' => $_POST['email'],
|
2022-11-02 22:36:20 +00:00
|
|
|
'admin' => 'n',
|
2022-11-02 15:39:55 +00:00
|
|
|
'password' => password_hash($_POST['password'], PASSWORD_DEFAULT)
|
|
|
|
|
];
|
|
|
|
|
$stmt->execute($values);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$pageTitle = 'iBuy - Register';
|
|
|
|
|
$pageContent = '<p>Already have an account?<a href=\'login.php\'>Click here to Login</a></p>
|
|
|
|
|
<h1>Register</h1>
|
|
|
|
|
<form action="register.php" method="POST">
|
2022-11-19 16:03:54 +00:00
|
|
|
<label>First Name</label> <input name="first_name" type="text" placeholder="John"/>
|
|
|
|
|
<label>Last Name</label> <input name="last_name" type="text" placeholder="Doe"/>
|
|
|
|
|
<label>Email</label> <input name="email" type="text" placeholder="john.doe@example.com"/>
|
|
|
|
|
<label>Password</label> <input name="password" type="text" placeholder="password"/>
|
2022-11-02 15:39:55 +00:00
|
|
|
<input name="submit" type="submit" value="Submit" />
|
|
|
|
|
</form>';
|
2022-11-19 15:38:26 +00:00
|
|
|
|
2022-11-02 15:39:55 +00:00
|
|
|
require '../../layout.php';
|
|
|
|
|
|
|
|
|
|
if (isset($_POST['submit'])) {
|
|
|
|
|
addUser();
|
|
|
|
|
echo '<p>Successful account creation</p>';
|
|
|
|
|
}
|
|
|
|
|
?>
|