Forum Moderators: coopster

Message Too Old, No Replies

help validating form

         

adammc

3:21 am on Feb 21, 2007 (gmt 0)

10+ Year Member



Hi Folks,

Can anyone possible help, this is driving me nuts :(

This form locks up (just hangs in the process if $errors isnt empty?

If there is no error detected it works fine

[PHP]if (isset($_POST['submit-form'])) { // Handle the form if its been posted

$errors = array(); // Initialize error array.

// validate first_name
if ((ctype_alpha($user) == FALSE ))
$errors[] = "Please enter an email account name that consists only of letters and numbers only.";

// validate password1
if ((ctype_alpha($password1) == FALSE ))
$errors[] = "Please enter a password that consists only of letters and numbers only.";

// validate password2
if ((ctype_alpha($password2) == FALSE ))
$errors[] = "Please enter a password that consists only of letters and numbers only.";

// Check for a password and match against the confirmed password.

if ($_POST['password1'] == $_POST['password2']) {
$p = ($_POST['password1']);
} else {
$errors[] = 'Your password did not match the confirmed password!';
}

if (empty($errors)) { // If everything went okay

// do something

} else { // if errors array contains a value

echo "<table align=\"center\"><tr><td>The following error(s) occurred:<br />";
foreach ($errors as $msg) { // Print each error.
echo "$msg<br />\n";
}
echo '</td></tr></table>';

} // End of if (empty($errors))

[/PHP]

cameraman

7:29 am on Feb 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only thing I see wrong is you're missing a closing brace.

dreamcatcher

8:22 am on Feb 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



adammc, try setting your error reporting to E_ALL to see if that throws any clues.

dc