heres some of my regisration script that i use take no notice of the javascript as it splits the form into smallers sections and uses ajax validation on the client side.
Ive had to cut code but you should be able to understand it.
<body>
<form id="contactform" action="register.php" method="post">
<div id="partOne" style="width:640px">
<fieldset><legend>Personal Details-All fields Required</legend>
<table width="600" align="center" cellpadding="2px">
<tr>
<td width="300" align="right" class="inside"><label>First Name: <input type="text" name="firstName" id="firstName" onchange="checkForm(this.value, this.id)" value="<?php if (isset($_POST['firstName'])) echo $_POST['firstName']; ?>"></label></td><td align="left" class="inside"><label id="firstNamev" class="error"></label></td>
</tr>
<tr>
<td width="300" align="right" class="inside"><label>Middle Name: <input type="text" name="middleName" id="middleName" onchange="checkForm(this.value, this.id)" value="<?php if (isset($_POST['middleName'])) echo $_POST['middleName']; ?>" /></label></td><td align="left" class="inside"><label id="middleNamev" class="error"></label></td>
</tr>
<tr>
<td width="300" align="right" class="inside"><label>last Name: <input type="text" name="lastName" id="lastName" onchange="checkForm(this.value, this.id)" value="<?php if (isset($_POST['lastName'])) echo $_POST['lastName']; ?>" /></label></td><td align="left" class="inside"><label id="lastNamev" class="error"></label></td>
</tr>
<tr><td><a tabindex="4" onclick="show('partTwo');return false;" onkeypress="show('partTwo');return false;" href="#partTwo">» Next</a></td></tr>
</table></fieldset>
</div>
<div id="partTwo" style="width:640px">
<fieldset><legend>login Details-All fields Required</legend>
<table width="640" align="center" cellpadding="2px">
<tr>
<td width="300" align="right" class="inside"><label>Login Name: <input type="text" name="loginName" id="loginName" style="border-style: solid; border-width:1px;" onChange="checkForm(this.value, this.id)" value="<?php if (isset
($_POST['loginName'])) echo $_POST['loginName']; ?>" /></label></td><td align="left" class="inside"><label id="loginNamev" class="error"></label></td>
</tr>
<tr>
<td width="300" align="right" class="inside"><label>Password: <input type="password" name="password" id="password" style="border-style: solid; border-width:1px;" onChange="checkForm(this.value, this.id)" value="<?php if(isset($_POST['password'])) echo $_POST['password']; ?>" /></label></td><td align="left" class="inside"><label id="passwordv" class="error"></label></td>
</tr>
<tr>
<td width="300" align="right" class="inside"><label>Confirm Password: <input type="password" name="confirmPassword" id="confirmPassword" style="border-style: solid; border-width:1px;" onChange="checkForm(this.value, this.id)" value="<?php if(isset($_POST['confirmPassword'])) echo $_POST['confirmPassword']; ?>" /></label></td><td align="left" class="inside"><label id="confirmPasswordv" class="error"></label></td>
</tr>
<tr><td><a tabindex="9" onclick="show('partOne'); return false;" onkeypress="show('partOne'); return false;" href="#partOne">« Back</a> |
<a tabindex="8" onclick="show('partThree'); return false;" onkeypress="show('partThree'); return false;" href="#partThree">Next »</a></td></tr></table></fieldset>
</div>
<div id="partFive" style="width:640px">
<h2>Finished</h2>
<p>Thank you for taking the time to enter your details. Please use the "Register"; button
to submit your details.</p>
<p>Or press the "Make Changes" link if you feel you are wrong in any details".</p>
<input style="margin:40px 0" tabindex="10" type="submit" name="submit" value="Register" />
<input name="submitted" type="hidden" value="TRUE" />
<p><a tabindex="11" onclick="show('partFour'); return false;" onkeypress="show('partFour'); return false;" href="#partFour">
« Make Changes</a></p>
</div>
</form>
</body>
</html>
<?php
/**
* @Author Kevin Nally
* @Description Registration Form with email activation and field validation
* @Year 3 2008
* @Subject Software Project
*/
require_once('errorhandling.php');
ini_set("SMTP", "example.com");
ini_set("sendmail_from", "example@example.net");
if (isset($_POST['submitted'])) {
require_once ('mysqlConnection.php'); // Connect to the db.
// Create a function for escaping the data.
function escape_data($data)
{
global $dbc; // Need the connection.
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string(trim($data), $dbc);
} // End of function.
$errors = array();
if (empty($_POST['firstName']))
{
$errors[] = 'You forgot to enter your first name.';
}
else
{
$firs = escape_data($_POST['firstName']);
}
if (empty($_POST['middleName']))
{
$errors[] = 'You forgot to enter your middle name.';
}
else
{
$midName = escape_data($_POST['middleName']);
}
if (empty($_POST['lastName']))
{
$errors[] = 'You forgot to enter your last name.';
}
else
{
$lastName = escape_data($_POST['lastName']);
}
if (empty($_POST['loginName']))
{
$errors[] = 'You must enter your login id';
}
else
{
$loginName = escape_data($_POST['loginName']);
}
if(!empty($_POST['password']))
{
if($_POST['password']!=$_POST['confirmPassword'])
{
$errors[]='Your Passwords do not match';
}
else
{
$pass=escape_data($_POST['confirmPassword']);
}
}
else
{
$errors[]='You forgot to enter your Password';
}
if (empty($errors)) {
$query = "SELECT password FROM users WHERE password='$pass'";
$result = mysql_query($query);
if (mysql_num_rows($result) == 0) {
$query = "INSERT INTO users (firstName, middleName,lastname,loginName,password) VALUES ('$firstName','$midName','$lastName','$loginName','$pass',')";
$result = @mysql_query($query); // Run the query.
if ($result) { // If it ran OK.
echo '<h1 id="mainhead">Thank you!</h1>
<p>You are now registered. A confirmation email has been sent to you please follow its instructions</p>';
$emailBody = "Thank You for registering. To activate your account, please click on this link:\n\n";
$emailBody .= "htpp://www.example.net/activate.php?x=" . mysql_insert_id() .
"&y=$a";
mail($_POST['email'], 'Registration Confirmation', $emailBody);
exit();
} else {
echo '<h1 id="mainhead">System Error</h1>
<p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; // Public message.
echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query . '</p>'; // Debugging message.
exit();
}
} else {
echo '<h1 id="mainhead">Error!</h1>
<p class="error">The email address has already been registered.</p>';
}
} else {
echo '<h1 id="mainhead">Error!</h1>
<p class="error">The following error(s) occurred:<br />';
foreach ($errors as $msg) { // Print each error.
echo " - $msg<br />\n";
}
echo '</p><p>Please try again.</p><p><br /></p>';
}
mysql_close();
}
?>
:cool: