Repository navigation
Expand file tree
/
Copy pathCreateAccount.php
More file actions
84 lines (67 loc) · 1.87 KB
/
Copy pathCreateAccount.php
File metadata and controls
84 lines (67 loc) · 1.87 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* Created by PhpStorm.
* User: dronca
* Date: 10/20/18
* Time: 8:51 PM
*/
include 'lib/DBHelper.php';
include 'lib/Cookies.php';
session_start();
$dbh = new DBHelper();
$msg = "hmmm!";
if(isset($_POST['email']) AND isset($_POST['psw'])) {
$query = "SELECT firstName, lastName, emailAddress, groupID, password FROM TeamAlphaMarket.User WHERE emailAddress='{$_POST['email']}' ";
$result = $dbh->query($query) or die("The email or password you entered is not valid");
$fname = $_POST['firstName'];
$lname = $_POST['lastName'];
$email = $_POST['email'];
$pwd = $_POST['psw'];
$cpwd = $_POST['psw_c'];
$addr = $_POST['addr'];
$apt = $_POST['apt'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$cellPhone = $_POST['cellPhone'];
$row = mysqli_fetch_array($result);
$ref = $_SESSION['ref'];
$pathParts = explode("/", $ref);
$page = end($pathParts);
if($row == null && $pwd == $cpwd)
{
$add = "INSERT INTO TeamAlphaMarket.User (firstName, lastName, emailAddress, streetAddress, apt, city, state, zipCode, homePhone, cellPhone, groupID, password)";
$values = "VALUES('$fname', '$lname', '$email', '$addr', '$apt', '$city', '$state', '$zip', '$phone', '$cellPhone', 'Customer', '$pwd')";
$query = $add." ".$values;
error_log($query);
$dbh->query($query);
$hdr = "Location: $page";
header($hdr);
}
else if($pwd != $cpwd)
{
$msg = "Passwords do not match";
}
else
{
$msg = "Account already exists";
$msg = "Account already exists";
}
}
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body >
<?php echo($page); ?>
<?php echo($msg); ?>
</body>
</html>
<?php
//Step 4
$dbh->close();
?>