Jump to content

Empty field check


Bounty

Recommended Posts

I really don't remember erasing that :S

 

Anyhow it works now all the way to:

	if( !empty($_POST['password2']) ) { // same validations as in name, above.
	if($_POST['password2'] != $_POST['password'])  {
		$error = 'Passwords do not match.' . 
		$errors[] = $error;
	}
} else {
	$errors[] = 'Confirm your password.';
}

Script always jumps to this error "Confirm your password." even if:

    [password] => abc
    [pass_conf] => abc 

Fixed that...it was a type mistake...now the final thing...

I tried to add [action=do_reg.php] inside form brackets but it wont work..it just jumps over whole script to do_reg.php...so how should i continue the registration after the checking fields...should i add [include 'do_reg.php';] at the end of the php before }?

No. Anything within that conditional will only be executed if the form is submitted with errors, or the form is not submitted. Assuming you want the do_reg script to run when the script has been submitted, and there are NO errors, you would need to add an else{} to go with the if( !empty(errors) ) { conditional.

 

if( !empty($errors) ) {  // if the $errors array is not empty, display the errors to allow the user to correct them and resubmit the form
	echo "<font color=\"red\">The following errors were detected:<br>";
	echo implode("<br>\n", $errors);
	echo '</font>';
} else {
// Code here would be executed if the form has been submitted with no errors.
}

It works almost perfectly but it shows error at:

			$errors[] = $error;

Output:

 

For the code back in reply 25, it looks like you have an error:

 

<?php
...

$error = 'Passwords do not match.' .
$errors[] = $error;

...
?>

 

 

There should be a semi-colon after the line that assigns the value to $error instead of a period. If that's doesn't fix the issue, it might be helpful to post the most recent code.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.