Hello,
I have this project of a registration form. What is required for us to do is to create a multi-page form. I did some code and trials but it seems that I come up with a problem I can't resolved. My problem is that I can't passed the variables to the next form. I'm having this error in session_start(). Can someone please help me.
Here is my code.
<?php
include 'db_connect.php';
if(!$_POST['submit'])
{
?>
<form method="post" action="register_step1.php">
<label>Username
<span class="small">Min. size 6</span>
</label>
<input type="text" name="username" maxlength="20" />
<label>Password
<span class="small">Min. size 6</span>
</label>
<input type="password" name="password" maxlength="16" />
<label>Confirm Password
<span class="small">retype your password</span>
</label>
<input type="password" name="confirm_password" maxlength="16" />
<label>E-mail
<span class="small">Ex. juan@domain.com</span>
</label>
<input type="text" name="emailadd" maxlength="30" />
<label>Confirm E-mail
<span class="small">retype your email</span>
</label>
<input type="text" name="confirm_emailadd" maxlength="30" />
<input type="submit" name="submit" value="Submit" class="button" />
<div class="spacer"></div>
</form>
<?php
}
else
{
$username = cleanString($_POST['username']);
$password = $_POST['password'];
$confirm_password = $_POST['confirm_password'];
$emailadd = cleanString($_POST['emailadd']);
$confirm_emailadd = cleanString($_POST['confirm_emailadd']);
$errors = array();
if(!$username || !$password || !$confirm_password || !$emailadd)
{
$errors[] = "Fill-up all the fields.";
}
$sql_user = mysql_query("SELECT * FROM users WHERE username = '$username'");
if(mysql_num_rows($sql_user) != 0)
{
$errors[] = "Username is already registered.";
}
if(strlen($username) < 5)
{
$errors[] = "Minimum length of username is six characters.";
}
if($password != $confirm_password)
{
$errors[] = "Password did not match.";
}
if($emailadd != $confirm_emailadd)
{
$errors[] = "Email address did not match.";
}
$sql_email = mysql_query("SELECT * FROM users WHERE emailadd = '$emailadd'");
if(mysql_num_rows($sql_email) != 0)
{
$errors[] = "Email address is already registered.";
}
if(strlen($password) < 5)
{
$errors[] = "Minimum length of password is six (characters or numbers).";
}
if(!preg_match("/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i", $emailadd))
{
$errors[] = "Email address is not valid.";
}
if(count($errors) > 0)
{
echo "Please correct the following errors: <br /><ul>";
foreach($errors as $error)
{
echo "<li>" . $error . "</li>";
}
echo "</ul>";
echo "<a href=\"javascript:history.go(-1)\">Check your registration form</a>";
}
else
{
session_start();
$_SESSION['username'] = '$username';
require 'register_step2.php';
}
}
?>