-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathnewUserEB.php
More file actions
executable file
·186 lines (143 loc) · 5.52 KB
/
newUserEB.php
File metadata and controls
executable file
·186 lines (143 loc) · 5.52 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
require_once('config.php');
session_start();
#connect
$equip = mysql_connect($hostname_equip, $username_equip, $password_equip);
if (!$equip)
die("Error " . mysql_errno() . " : " . mysql_error());
# Select the DB
$db_selected = mysql_select_db($database_equip, $equip);
if (!$db_selected)
die("Error " . mysql_errno() . " : " . mysql_error());
$firstnameLabel = "Firstname:";
$firstnameName = "firstname";
$firstnameValue = $_POST[$firstnameName];
$lastnameLabel = "Lastname:";
$lastnameName = "lastname";
$lastnameValue = $_POST[$lastnameName];
$emailLabel = "Email:";
$emailName = "email";
$emailValue = $_POST[$emailName];
$phoneLabel = "Phone:";
$phoneName = "phone";
$phoneValue = $_POST[$phoneName];
$userIDLabel = "UserID:";
$userIDName = "userID";
$userIDValue = $_POST[$userIDName];
$submitName = "dataAction";
$submitValue = "Submit";
### Status variables ###
$statusMsg = ""; # Gives response back to user (i.e. "Thank you for your ...")
$hasErrors = 0; # Keeps track of whether there are input errors
# Check our inputs and perform any DB actions
#########################################################
if ($_POST[$submitName]==$submitValue)
{ # Someone wants to login
# Error Checking
$noFirstname = $noLastname = $noEmail = $noPhone = $noUserID = 0;
#$userid = 0;
$firstnameValue = trim($firstnameValue);
$lastnameValue = trim($lastnameValue);
$emailValue = trim($emailValue);
$phoneValue = trim($phoneValue);
$userIDValue = trim($userIDValue);
if (empty($firstnameValue))
{ $hasErrors = 1; $noFirstname = 1; $statusMsg = "There were errors in your registration info.";
}
if (empty($lastnameValue))
{ $hasErrors = 1; $noLastname = 1; $statusMsg = "There were errors in your registration info.";
}
if (empty($emailValue))
{ $hasErrors = 1; $noEmail = 1; $statusMsg = "There were errors in your registration info.";
}
if (empty($phoneValue))
{ $hasErrors = 1; $noPhone = 1; $statusMsg = "There were errors in your registration info.";
}
if (empty($userIDValue))
{ $hasErrors = 1; $noUserID = 1; $statusMsg = "There were errors in your registration info.";
}
if (!$hasErrors)
{ # This is a good submission
$firstnameValueDB = str_replace("'", "''", $firstnameValue);
$lastnameValueDB = str_replace("'", "''", $lastnameValue);
$emailValueDB = str_replace("'", "''", $emailValue);
$phoneValueDB = str_replace("'", "''", $phoneValue);
$userIDValueDB = str_replace("'", "''", $userIDValue);
# Look for this information in the DB
#$SqlStatement = "SELECT id, firstname, lastname, email, last_login FROM class06_member
# WHERE username='$usernameValueDB' AND password='$passwordValueDB' ";
# print $SqlStatement . "\n";
# Insert this information in the DB (REGISTERATION PAGE)
$SqlStatement = "INSERT INTO students (StudentID, FirstName, LastName, Email, Phone, ContractSigned)
VALUES ('$userIDValueDB', '$firstnameValueDB', '$lastnameValueDB', '$emailValueDB', '$phoneValueDB', '0')";
#print $SqlStatement . "\n";
# Run the query on the database through the connection
$result = mysql_query($SqlStatement,$equip);
if (!$result)
die("Error " . mysql_errno() . " : " . mysql_error());
//mysql_close($equip);
$Sql = "INSERT INTO student_class (StudentID, ClassID)
VALUES ('$userIDValueDB', '1')";
$result = mysql_query($Sql, $equip);
if (!$result)
die("Error " . mysql_errno() . " : " . mysql_error());
mysql_close($equip);
# Make sure the session data gets written
session_write_close();
# Now go to the member home page
header("Location: studentidEB.php");
exit;
}
}
include('includes/headingEB.html'); ?>
<html>
<body>
<form name="form" action="newUserEB.php" method="post">
<strong>New User Account Form</strong>
<p>
User ID: <input name="<?=$userIDName?>" value="<?=$userIDValue?>" type="text" id="userID">
<?php
# If we had a problem with the name, show error message here
if ($hasErrors && $noUserID)
{ print '<br><font color="#ff0000"><b>Please provide a User ID</b></font>';
}
?>
<p>
First Name: <input name="<?=$firstnameName?>" value="<?=$firstnameValue?>" type="text" id="firstName">
<?php
# If we had a problem with the name, show error message here
if ($hasErrors && $noFirstname)
{ print '<br><font color="#ff0000"><b>Please provide a Firstname</b></font>';
}
?>
<p>
Last Name: <input name="<?=$lastnameName?>" value="<?=$lastanameValue?>" type="text" id="lastName">
<?php
# If we had a problem with the name, show error message here
if ($hasErrors && $noLastname)
{ print '<br><font color="#ff0000"><b>Please provide a Lastname</b></font>';
}
?>
<p>
E-mail: <input name="<?=$emailName?>" value="<?=$emailValue?>" type="text" id="eMail">
<?php
# If we had a problem with the name, show error message here
if ($hasErrors && $noEmail)
{ print '<br><font color="#ff0000"><b>Please provide an E-Mail Address</b></font>';
}
?>
<p>
Phone: <input name="<?=$phoneName?>" value="<?=$phoneValue?>" type="text" id="phone">
<?php
# If we had a problem with the name, show error message here
if ($hasErrors && $noPhone)
{ print '<br><font color="#ff0000"><b>Please provide a Phone Number</b></font>';
}
?>
<p>
<input type="submit" name="<?=$submitName?>" value="<?=$submitValue?>">
</form>
<? include('includes/footerEB.html'); ?>
<? mysql_close($equip); ?>
</body>
</html>