-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclientSignup.php
More file actions
45 lines (31 loc) · 1.31 KB
/
Copy pathclientSignup.php
File metadata and controls
45 lines (31 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
session_start();
include 'databaseConnection.php';
if($error != null){
echo '<p> cant connect to DB';
}
else{
if(isset($_POST['email'])){
$select = "SELECT * FROM `client` WHERE `emailAddress` = ?";
$stmt = $connection->prepare($select);
$stmt->bind_param("s", $_POST['email']);
$stmt->execute();
$result = $stmt->get_result();
if($result->num_rows > 0) {
echo '<script> alert("this email is already being used, please log in instead"); window.location.href="logIn.html"; </script>';
exit();
}
}
if (isset($_POST['fname']) && isset($_POST['lname']) && isset($_POST['email']) && isset($_POST['pass']) ) {
$pass = password_hash($_POST['pass'], PASSWORD_DEFAULT);
$sql = "INSERT INTO `client` (`firstName`, `lastName`, `emailAddress`, `password`) VALUES (?, ?, ?, ?)";
$stmt = $connection->prepare($sql);
$stmt->bind_param("ssss", $_POST['fname'], $_POST['lname'], $_POST['email'], $pass);
$stmt->execute();
$lastInsertedID =$stmt->insert_id;
$_SESSION["userID"]=$lastInsertedID;
$_SESSION["userType"]='client';
header('Location:clientHomePage.php'); //change when code is ready
}
}
?>