Jump to content

Functions are not setting variables.


I-R-Fool

Recommended Posts

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

Archived

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

×
×
  • Create New...