Code: Select all
<LINK REL="stylesheet" type="text/css" href="main.css" />
<?php
// Membership signup form. html will go here.
//If form not yet submitted display form.
if (!isset($submit))
{
?>
<table cellspacing="5" cellpadding="5" border="0" width="75%" align="center">
<form action="<?=$_SERVERї'PHP_SELF']?>" method="post">
<tr>
<td valign="top"><b><font size="-1">Temporary User ID.</font></b> <font color="red">Do not forget this user id you will need it to complete your signup</td>
<td><input size="50" maxlength="250" type="text" name="temp_id"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Database Password</font></b></td>
<td><input size="50" maxlength="250" type="password" name="password"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Verify Database Password</font></b></td>
<td><input size="50" maxlength="250" type="password" name="verifypassword"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Surname</font></b></td>
<td><input size="50" maxlength="250" type="text" name="surname"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Firstname</font></b></td>
<td><input size="50" maxlength="250" type="text" name="firstname"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Middle Name (Not Required)</font></b></td>
<td><input size="50" maxlength="250" type="text" name="middlename"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Family Members</font></b></td>
<td><input size="50" maxlength="250" type="text" name="familymembers"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Street Number</font></b></td>
<td><input size="50" maxlength="250" type="text" name="st_num"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Street Name</font></b></td>
<td><input size="50" maxlength="250" type="text" name="st_name"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Suburb / Town / City</font></b></td>
<td><input size="50" maxlength="250" type="text" name="suburb_town_city"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Post Code</font></b></td>
<td><input size="50" maxlength="250" type="text" name="postcode"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Country</font></b></td>
<td><input size="50" maxlength="250" type="text" name="country"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Home Phone No.</font></b></td>
<td><input size="50" maxlength="250" type="text" name="ph_home"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Business Phone No.</font></b></td>
<td><input size="50" maxlength="250" type="text" name="ph_business"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Mobile Phone No.</font></b></td>
<td><input size="50" maxlength="250" type="text" name="ph_mobile"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">E-mail Address</font></b></td>
<td><input size="50" maxlength="250" type="text" name="email"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Occupation</font></b></td>
<td><input size="50" maxlength="250" type="text" name="occupation"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Interests</font></b></td>
<td><input size="50" maxlength="250" type="text" name="interests"></td>
</tr>
<tr>
<td valign="top"><b><font size="-1">(Companies Purchases Only) Name of Nominated Person</font></b></td>
<td><input size="50" maxlength="250" type="text" name="nominated_person"></td>
</tr>
<tr>
<td><input type="submit" name="submit" Value="Continue"></td>
</tr>
</form>
</table>
<?
}
else
{
$errorlist = array();
$count = 0;
$dbconn = mysql_connect("localhost", "user", "pass") or die ("Unable to connect!");
mysql_select_db("db", $dbconn) or die ("Unable to select database!");
$query = "SELECT temp_id FROM members WHERE temp_id='$temp_id'";
$result = mysql_query($query) or die("Query failed at username unique testing stage.");
$num_rows = mysql_num_rows($result);
if ($num_rows == 1) { $errorlistї$count] = "Your Temporary Id is already in use. Please click back and enter another temporary id"; $count++; }
mysql_close($dbconn);
if ($password!=$verifypassword) { $errorlistї$count] = "Your Entered Passwords Do Not Match"; $count++; }
if (!isset($temp_id)) { $errorlistї$count] = "Required feild: Temporary ID returned a null value"; $count++; }
if (!isset($surname)) { $errorlistї$count] = "Required feild: Surname returned a null value"; $count++; }
if (!isset($firstname)) { $errorlistї$count] = "Required feild: Firstname returned a null value"; $count++; }
if (!isset($familymembers)) { $errorlistї$count] = "Required feild: Family Members returned a null value"; $count++; }
if (!isset($st_num)) { $errorlistї$count] = "Required feild: Street No. returned a null value"; $count++; }
if (!isset($st_name)) { $errorlistї$count] = "Required feild: Street Name returned a null value"; $count++; }
if (!isset($suburb_town_city)) { $errorlistї$count] = "Required feild: Suburb / Town / City returned a null value"; $count++; }
if (!isset($postcode)) { $errorlistї$count] = "Required feild: Postcode returned a null value"; $count++; }
if (!isset($country)) { $errorlistї$count] = "Required feild: Country returned a null value"; $count++; }
if (!isset($ph_home)) { $errorlistї$count] = "Required feild: Home Phone No. returned a null value"; $count++; }
if (!isset($email)) { $errorlistї$count] = "Required feild: E-mail returned a null value"; $count++; }
if (!isset($occupation)) { $errorlistї$count] = "Required feild: Occupation returned a null value"; $count++; }
if (!isset($interests)) { $errorlistї$count] = "Required feild: Interests returned a null value"; $count++; }
if (sizeof($errorlist) == 0)
{
$dbconn = mysql_connect("localhost", "user", "pass") or die ("Unable to connect!");
mysql_select_db("db", $dbconn) or die ("Unable to select database!");
$encryptedpassword = md5($password);
$query = "INSERT INTO members(temp_id, password, surname, firstname, middlename, familymembers, st_num, st_name, suburb_town_city, postcode, country, ph_home, ph_business, ph_mobile, email, occupation, interests, nominated_person) VALUES('$temp_id', '$encryptedpassword', '$surname', '$firstname', '$middlename', '$familymembers', '$st_num', '$st_name', '$suburb_town_city', '$postcode', '$country', '$ph_home', '$ph_business', '$ph_mobile', '$email', '$occupation', '$interests', '$nominated_person')";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
echo "Entry successful. <a href=confirmed.php>Click Here To Finish Signup</a>.";
mysql_close($dbconn);
}
else
{
echo "The Following Errors Were Incountered:<br />";
echo "<ul>";
for ($x=0; $x<sizeof($errorlist); $x++)
{
echo "<li>$errorlistї$x]";
}
echo "</ul>";
}
}
?>