Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $page_title = 'Register';
- include ('header.html');
- if (isset($_POST['submitted'])) {
- $errors = array();
- if (empty($_POST['first_name'])) {
- $errors[] = 'You forgot to enter your first name.';
- } else {
- $fn = trim($_POST['first_name']);
- }
- if (empty($_POST['last_name'])) {
- $errors[] = 'You forgot to enter your last name.';
- } else {
- $ln = trim($_POST['last_name']);
- }
- if (empty($_POST['email'])) {
- $errors[] = 'You forgot to enter your email address.';
- } else {
- $e = trim($_POST['email']);
- }
- if (empty($_POST['phone'])) {
- $errors[] = 'You forgot to enter your phone number.';
- } else {
- $ph = trim($_POST['phone']);
- }
- if (empty($_POST['address_line1'])) {
- $errors[] = 'You forgot to enter your billing address.';
- } else {
- $ad1 = trim($_POST['address_line1']);
- }
- if (empty($_POST['suburb'])) {
- $errors[] = 'You forgot to enter your City/Suburb.';
- } else {
- $s = trim($_POST['suburb']);
- }
- if (empty($_POST['postcode'])) {
- $errors[] = 'You forgot to enter your postcode.';
- } else {
- $pc = trim($_POST['postcode']);
- }
- if (empty($_POST['username'])) {
- $errors[] = 'You forgot to enter a username.';
- } else {
- $un = trim($_POST['username']);
- }
- if (!empty($_POST['pass1'])) {
- if ($_POST['pass1'] !=
- $_POST['pass2']) {
- $errors[] = 'Your password did not match the confirmed password.';
- } else {
- $p = trim($_POST['pass1']);
- }
- } else {
- $errors[] = 'You forgot to enter a password.';
- }
- if (empty($errors)) {
- require_once
- ('mysqli_connect.php');
- $q = "INSERT INTO users (first_name, last_name, email, phone, address_line1, suburb, postcode, username, pass, registration_date) VALUES ('$fn', '$ln', '$e', '$ph', '$ad1', '$s', '$pc', '$un', SHA1('$p'), NOW() )";
- $r = @mysqli_query ($dbc, $q);
- if ($r) {
- echo '<h1>Thank you!</h1>
- <p>You are now registered.</p><p><br /></p>';
- } else {
- echo '<h1>System Error</h1>
- <p class="error">You could not be registered due to a system error. We apologise for any inconvenience.</p>';
- echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>';
- }
- mysqli_close($dbc);
- include ('footer.html');
- exit();
- } else {
- echo '<h1>Error!</h1>
- <p class="error">The following error(s) occurred: <br />';
- foreach ($errors as $msg) {
- echo " - $msg<br />\n";
- }
- echo '</p><p>Please try again.</p><p><br /></p>';
- }
- }
- ?>
- <div id="maincontent">
- <fieldset><legend>
- <h2>Register:</h2>
- </legend>
- <form action="register.php" method ="post">
- <p>First name: <br /><input type="text" name="first_name" size="60" maxlength="20" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></p>
- <p>Last name: <br /><input type="text" name="last_name" size="60" maxlength="40" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /></p>
- <p>Email address: <br /><input type="text" name="email" size="60" maxlength="80" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p>
- <p>Phone: <input type="text" name="phone" size="20" maxlength="20" value="<?php if (isset($_POST['phone'])) echo $_POST['phone']; ?>" /></p>
- <p>Company name: <br /><input type="text" name="company_name" size="60" maxlength="100" value="<?php if (isset($_POST['company_name'])) echo $_POST['company_name']; ?>" /></p>
- <p>Billing address: <br /><input type="text" name="address_line1" size="60" maxlength="80" value="<?php if (isset($_POST['address_line1'])) echo $_POST['address_line1']; ?>" /></p>
- <p>Billing address (con't): <br /><input type="text" name="address_line2" size="60" maxlength="80" value="<?php if (isset($_POST['address_line2'])) echo $_POST['address_line2']; ?>" /></p>
- <p>City/Suburb: <br /><input type="text" name="suburb" size="60" maxlength="80" value="<?php if (isset($_POST['suburb'])) echo $_POST['suburb']; ?>" /></p>
- <p>State: <br /><input type="text" name="state" size="20" maxlength="3" value="<?php if (isset($_POST['state'])) echo $_POST['state']; ?>" /></p>
- <p>Postcode: <br /><input type="text" name="postcode" size="20" maxlength="10" value="<?php if (isset($_POST['postcode'])) echo $_POST['postcode']; ?>" /></p>
- <p>Username: <br /><input type="text" name="username" size="60" maxlength="80" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p>
- <p>Password: <br /><input type="password" name="pass1" size="60" maxlength="20" /></p>
- <p>Confirm Password: <br /><input type="password" name="pass2" size="60" maxlength="20" /></p>
- <p><input type="submit" name="submit" value="Register" /></p>
- <input type="hidden" name="submitted" value="TRUE" />
- </form>
- </fieldset>
- </div>
- <?php
- include ('footer.html');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement