Once I validate the user info on a form, how do I send it on to another page?
For example:
user inputs information and clicks submit.
the submit button sends the data back to the page again, using PHP_SELF.
the script processes the data, and determines that it's accurate
the script inserts it into the mySQL database
once this happens, i need it to also send the values of the posted variables to another page, and take the user there.
Is there such a thing as a hidden 'clickless' submit button, or a function/command that does that?
for example:
if (data_is_good)
{
submit_data_to (nextpage.php);
}
The idea being that page one takes requested user name, desired password, and email address, checks the input for errors, and then does one of the following:
If the Email address already exists in the database, it goes to a 'forgot password page' (and hopefully fills in the email fild for them, so they only have to click 'submit password reset request')
If all the data checks out, it goes to another form that greets them by thier new username, and asks for real name / phone number / address / etc.
Warning: Cannot modify header information - headers already sent by (output started at /home/rahl/public_html/RVM/registration/register1.1.php:2) in /home/rahl/public_html/RVM/include/functions.php on line 82
That happens when you are already displaying something on the page - which doesn't make sense if you're going to redirect to another page.
You probably have to restructure your script so that a redirect happens first - if the conditions are met - and information is only output if the conditions for a redirect do not exist, i.e. failed validation.
Post the script and we'll find a logical spot for it.
Otherwise, you can do output bufffering until you decide whether to redirect or not - see the manual for ob_start(), ob_end_flush() and ob_end_clean().
if (empty($user_name))
{
$error .= "<li>Please choose a username</li>";
}
//verify that passwords have been entered, and that they match
if (empty($password1))
{
$error .= "<li>Please enter a password in both fields</li>";
}
elseif (empty($password2))
{
$error .= "<li>Please confirm your password</li>";
}
elseif ($password2 != $password1)
{
$error .= "<li>Your passwords don't match, please try again</li>";
}
// verify that the email address is in a valid format
if (empty($email_address))
{
$error .= "<Li>Please provide an email address</li>";
}
elseif(!eregi("^[A-Za-z0-9\_-]+@[A-Za-z0-9\_-]+.[A-Za-z0-9\_-]+.*", $email_address))
{
$error .= "<li>$email_address doesn't appear to be a valid email address</li>";
}
else
{ //if the email format is OK, check to see if it's already in the database.
$query = "SELECT * FROM Users WHERE email = '$email_address'";
$result = safe_query($query);
if (mysql_num_rows($result) >0)
{
$next_condition = 2; // email address already exists in database
}
}
//safe_query($query);
echo "Code here to foward user to 2nd registration page, and pass on the variable '$user_name'.";
}
elseif($next_condition == 2)
{
echo "code goes here to direct user to duplicate email address page";
}
elseif($next_condition == 3)
{
echo "code goes here to direct user to 'choose another username page'";
}
else
{
$error = "<ol>".$error."</ol>";
return $error;
}
}
And this is the function from 'registration_forms.php' that displays the form.
PHP Code:
<?PHP
// Store the registration forms as functions
function registration_form_1()
{
// Include the header information
Require('../include/header.php');
// declare global variables
global $ret_error;
global $email_address;
global $user_name;
global $password1;
global $password2;
if(empty($ret_error))
{
$ret_error = 'Please choose a user ID and password, and provide your email address.';
}
Bookmarks