I-R-Fool Posted April 15, 2010 Share Posted April 15, 2010 I'm working on a registration forum, using error codes to figure out what error the user made.So this is my reg_func.php code:(just 1 function of it. The rest is basically the same.) function PasswordCheck($pass, $pass2) { $_ERROR['Password'] = 0; if($pass != $pass2) { $_ERROR['Password'] = 1; } if($_ERROR['Password'] == 0 && $pass == '') { $_ERROR['Password'] = 2; } if($_ERROR['Password'] == 0 && strlen($pass) <= 5) { $_ERROR['Password'] = 3; } } I'm submitting my form to itself, and then checking if the form was submitted, the check is working(made an echo to see if it works) and using a switch for the errors. Inside the check, I'm calling the function withPasswordCheck($_POST['Password'], $_POST['PasswordCheck']);Then I'm echoing the error code. But its not being set. switch($_ERROR['Password']) { case 0: break; case 1: echo 'Your passwords do not match.'; break; case 2: echo 'Your password is empty.'; break; case 3: echo 'Your username is too short. Min. 6 characters.'; break; } The problem is, the functions aren't setting the $_ERROR's.Any help? Link to comment Share on other sites More sharing options...
jeffman Posted April 15, 2010 Share Posted April 15, 2010 It looks like you want to use $_ERROR as a global, but you are not declaring it so. An option might be to return a value from PasswordCheck() indicating what the error is. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.