I was wondering if there was a way to request information from a form, and when the form is submitted continue the script (such as with JavaScript event handlers) I have a user logon script which, when an instance of the class 'User' is created, displays a form and uses the information to create the user in the database. However, what is happening is that the $_POST variables are being tested (i.e. if(isset(...)) ), and an error message is displayed before the user has inputted any information.
Here is my code:
function __construct() {
$this->displayForm();
$this->name = $_POST["setup_fullname"];
if(count(str_split($_POST["setup_usr"], 1)) > 4 && usrIsFree($_POST["setup_usr"])) {
$this->username = $_POST["setup_usr"];
print($this->username);
} else {
echo '<script type="text/javascript">alert("Invalid Username! Username may be taken or is under the character limit.")</script>';
unset($_POST['setup_sbmt']);
$this->displayForm();
}
if(count(str_split($_POST["setup_pwd"], 1)) > 4) {
$this->password = md5($_POST["setup_pwd"]) + saltify($this->username);
} else {
echo '<script type="text/javascript">alert("Invalid Password")</script>';
unset($_POST['setup_sbmt']);
$this->displayForm();
}
if(isset($_POST['kmli'])) { $this->keepSession = true; } else { $this->keepSession = false; }
}
}
By the end of it I get 2 JScript messages saying ("invalid password/username") and the form is displayed 3 times.
Thanks in advance
- James
Bookmarks