Created
May 26, 2011 23:49
-
-
Save nicoletirado/994378 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
include("includes/db.php"); | |
include("includes/functions.php"); | |
include("header.php"); | |
// If a user is logged in, it shows an error message saying the person can't register because he/she already has an account. | |
if(isset($_SESSION['username'])) { | |
echo "<h1 class=\"centered\">Error</h1><p class=\"centered\" style=\"color:red\">You can't register if you're already a user.</p>"; | |
} | |
else { | |
if (! empty($_POST['UserId']) && ! empty($_POST['Password'])) { | |
$username = $_POST['UserId']; | |
// Verifies if both passwords are equal | |
if ($_POST['Password'] == $_POST['Password2']) { | |
$password = $_POST['Password']; | |
} | |
else { | |
echo "Password Entry Confirmation was unsuccessful, please try again."; | |
} | |
$firstname = $_POST['FirstName']; | |
$lastname = $_POST['LastName']; | |
$address = $_POST['Address']; | |
$city = $_POST['City']; | |
$zipcode = $_POST['ZipCode']; | |
$state = $_POST['State']; | |
$email = $_POST['Email']; | |
$dphonenumber = $_POST['DPhoneNumber']; | |
$checkusername = mysql_query("SELECT * FROM Customer WHERE User_id = '".$username."'"); | |
// Checks if the username is already taken. | |
if (mysql_num_rows($checkusername) == 1) { | |
echo "<h2>Error</h2><p>That username is taken. Please go back and try again.</p>"; | |
} | |
else { | |
$register = mysql_query("INSERT INTO Customer VALUES('$username', '$password', '$firstname', '$lastname', '$address', '$city', '$zipcode', '$state', '$email', '$dphonenumber');"); | |
if ($register) { | |
echo "<div class=\"centered\"><h2>Success!</h2><p style=\"color:green\">Your account was successfully created. Please click <a href=\"login.php\">here</a> to login.</p></div>"; | |
} | |
else { | |
echo "<div class=\"centered\"><h2>Error!</h2><p>Sorry, your registration failed. Please try again.</p></div>"; | |
} | |
} | |
} | |
else { | |
?> | |
<h1 class="centered">Registration</h1> | |
<p> | |
<div id="registration_container"> | |
<form method="post" action="registration.php"> | |
<fieldset> | |
<label for="UserId">User ID*</label> <input type="text" name="UserId" id="UserId" /><br /> | |
<label for="Password">Password*</label> <input type="password" name="Password" id="Password" /><br /> | |
<label for="Password2">Confirm Password*</label> <input type="password" name="Password2" id="Password2" /><br /> | |
<label for="FirstName">First Name*</label> <input type="text" name="FirstName" id="FirstName" /><br /> | |
<label for="LastName">Last Name*</label> <input type="text" name="LastName" id="LastName" /><br /> | |
<label for="Address">Address*</label> <input type="text" name="Address" id="Address" /><br /> | |
<label for="City">City*</label> <input type="text" name="City" id="City" /><br /> | |
<label for="ZipCode">ZipCode*</label> <input type="text" name="ZipCode" id="ZipCode" /><br /> | |
<label for="State">State*</label> <select name="State" id="State"> | |
<option value="">Choose One</option> | |
<option>CA</option> | |
<option>FL</option> | |
<option>GA</option> | |
<option>HI</option> | |
<option>PA</option> | |
<option>PR</option> | |
<option>WA</option> | |
</select> | |
<br /><br /> | |
<label for="Email">Email*</label> <input type="text" name="Email" id="Email" /><br /> | |
<label for="DPhoneNumber">Daytime Phone Number</label> <input type="text" name="DPhoneNumber" id="DPhoneNumber" /><p></p> | |
</fieldset> | |
<div class="centered"><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></div><br /> | |
</form> | |
</div> | |
</p> | |
<? } | |
} ?> | |
<? include ("footer.php") ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment