Location: PHPKode > projects > Gsys > php/user_registration.php
<?PHP
//Filename : user_registration.php
//Description :  Allow users to apply for access
//Author :  darc
//Last modified :  2006.01.03
include ('../includes/vars.php');
if($_POST['submitted'] == "TRUE")
{
/*
include('../includes/sql_clean.php');

//sanitize input
$un = sql_quote($_POST['username']);
$pw = sql_quote($_POST['password']);
$repw =  sql_quote($_POST['password_retyped']);
$fn = sql_quote($_POST['f_name']);
$ln = sql_quote($_POST['l_name']);
$em = sql_quote($_POST['email']);
$mn = sql_quote($_POST['m_name']);  //new
$nick = sql_quote($_POST['nickname']);  //new
$phone = sql_quote($_POST['phone']);  //new
$address = sql_quote($_POST['address']);  //new
$town = sql_quote($_POST['town']);  //new
$state = sql_quote($_POST['state']);  //new
$zip = sql_quote($_POST['zip']);  //new
$ssn = sql_quote($_POST['ssn']);  //new
$stu_num = sql_quote($_POST['stu_num']);  //new
$init_date = sql_quote($_POST['initiation_date']);  //new
$dob = sql_quote($_POST['dob']);  //new
$on_off = sql_quote($_POST['on_off_campus']);  //new

*/
$un = $_POST['username'];
$pw = ($_POST['password']);
$repw =  ($_POST['password_retyped']);
$fn = ($_POST['f_name']);
$ln = ($_POST['l_name']);
$em = ($_POST['email']);
$mn = ($_POST['m_name']);  //new
$nick = ($_POST['nickname']);  //new
$phone = ($_POST['phone']);  //new
$address = ($_POST['address']);  //new
$town = ($_POST['town']);  //new
$state = ($_POST['state']);  //new
$zip = ($_POST['zip']);  //new
$ssn = ($_POST['ssn']);  //new
$stu_num = ($_POST['stu_num']);  //new
$init_date = ($_POST['initiation_date']);  //new
$dob = ($_POST['dob']);  //new
$on_off = ($_POST['on_off_campus']);  //new

//make sure all fields completed
if($un == "" || $pw == "" || $repw == "" || $fn == "" || $ln == "" || $em == "")
{
$error = "All fields are required.";
}
else
{
//make sure passwords typed match
if($pw != $repw)
$error = "You typed two different passwords";
else
{
//make db connection
include('../includes/db.php');
//detect username duplication
$sql = "SELECT * FROM brothers WHERE username = '$un'";
$result = mysql_query($sql,$connection) or die(mysql_error());
//count rows returned
$num = mysql_num_rows($result);
//if 1 or more rows, username already used
if($num >
0)
$error = "Username already in use";
else
{
//Detect email duplication
$sql = "SELECT * FROM brothers WHERE email = '$em'";
$result = mysql_query($sql,$connection) or die(mysql_error());
//count rows returned
$num = mysql_num_rows($result);
//if 1 or more rows, email already used
if($num >
0)
$error = "Email address already registered";
else //all happy, insert user.
{
//Indicate user is pending approval
$status = "pending";
//build insert statement
$sql = "INSERT INTO brothers (pin_num, username, password, email, l_name, m_name, f_name, nickname, phone, address, town, state, zip,ssn, stu_num, initiation_date, dob, on_off_campus, status, pos, auth) VALUES ('', '$un', PASSWORD('$pw'), '$em', '$ln', '$mn', '$fn', '$nick', '$phone', '$address', '$town', '$state', '$zip', '$ssn', '$stu_num', '$init_date', '$dob', '$on_off', '$status', 'none', 'none')";
$result = mysql_query($sql,$connection) or die(mysql_error());
$success = "$un successfully submitted for administrator approval";
unset($un, $fn, $ln, $em);
}
}
}
}
}

//edit for page title
$title = "Account Registration";
?>
<html>
<head>
  <title>
  <?php echo "".$chapter." :: " .$title. " :: " .$school.""; ?>
  </title>
  <link href="../includes/index.css" rel="stylesheet" type="text/css">
  </head>
  <body class="body">
  <br />
  <center>
    
    <img src="
    <?php echo $banner;?>
    "  />
  </center>
  <br />
  <?PHP echo $error; echo $success; echo "<br /><br />"; ?>
  <!-- FORM -->
  <form method="post" action="user_registration.php">
    *First Name: <INPUT TYPE="text" NAME="f_name" SIZE="30">
    <br />
    Middle Name: <INPUT TYPE="text" NAME="m_name" SIZE="30">
    <br />
    *Last Name: <INPUT TYPE="text" NAME="l_name" SIZE="30">
    <br />
    *Desired Username:  <INPUT TYPE="text" NAME="username" SIZE="30">
    <br />
    *Password:  <INPUT TYPE="password" NAME="password" SIZE="30">
    <br />
    *Re-Type Password:  <INPUT TYPE="password" NAME="password_retyped" SIZE="30">
    <br />
    *E-mail:  <INPUT TYPE="text" NAME="email" SIZE="30">
    <br />
    Nickname: <INPUT TYPE="text" NAME="nickname" SIZE="30">
    <br />
    *Phone Number: <INPUT TYPE="text" NAME="phone" SIZE="30" value="XXX-XXX-XXXX">
    <br />
    Address: <INPUT TYPE="text" NAME="address" SIZE="30" value="123 Monkey Street">
    <br />
    Town:  <INPUT TYPE="text" NAME="town" SIZE="30" value="Russellville">
    <br />
    State:  <INPUT TYPE="text" NAME="state" SIZE="4" value="AR">
    <br />
    Postal Code:  <INPUT TYPE="text" NAME="zip" SIZE="10">
    <br />
    SIN#:  <INPUT TYPE="text" NAME="ssn" SIZE="11" value="123-456-789">
    <br />
    STU#:  <INPUT TYPE="text" NAME="stu_num" SIZE="8" value="stuXXXXX">
    <br />
    Date of Birth:  <INPUT TYPE="text" NAME="dob" SIZE="11" value="YYYY-MM-DD">
    <br />
    *Initiation Date: <INPUT TYPE="text" NAME="initiation_date" SIZE="11" value="YYYY-MM-DD">
    <br />
    On or Off Campus Residency:
    <input type="radio" name="on_off_campus" value="on" checked>
    On Campus
    <input type="radio" name="on_off_campus" value="off">
    Off Campus
    <br />
    <br />
    <input type="hidden" name="submitted" value="TRUE" />
    <input type="submit" name="submit" value="Register" />
  </form>
  <!-- END FORM-->
  <br />
<?php include ('../includes/footer.php'); ?>
Return current item: Gsys