ilikephp Posted May 19, 2009 Share Posted May 19, 2009 hi, when these fields are checked, I want the submit button to open the response.php page. if it contains errors they will be fixed and if no response.php will open when clicked on it. is it possible to do it? Thanks... I put this code, but it is wrong :S <?php if (!isset($error['name']) && !isset($error['email']) && !isset($error['password']) && !isset($error['accept']) ){ }?> <input name="submit" type="submit" onClick="document.contactForm.action='response.php';" value="Submit"> Link to comment https://forums.phpfreaks.com/topic/158742-solved-php-validation/ Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 hi, when these fields are checked, I want the submit button to open the response.php page. if it contains errors they will be fixed and if no response.php will open when clicked on it. is it possible to do it? Thanks... I put this code, but it is wrong :S <?php if (!isset($error['name']) && !isset($error['email']) && !isset($error['password']) && !isset($error['accept']) ){ }?> <input name="submit" type="submit" onClick="document.contactForm.action='response.php';" value="Submit"> Huh? Link to comment https://forums.phpfreaks.com/topic/158742-solved-php-validation/#findComment-837200 Share on other sites More sharing options...
waiwai933 Posted May 19, 2009 Share Posted May 19, 2009 Well, it's possible and not possible. First though, your code would better be off with <?php if (!isset($error['name']) && !isset($error['email']) && !isset($error['password']) && !isset($error['accept'])) { echo ("<input name=\"submit\" type=\"submit\" onClick=\"document.contactForm.action='response.php';\" value=\"Submit\">"); } ?> The problem with your existing code was that it didn't pass anything through the brackets, which are the "then" part of "if..then..else". However, if you want it to update every moment, (this script only changes on page refresh, which might still break the script) then you should try Javascript. Link to comment https://forums.phpfreaks.com/topic/158742-solved-php-validation/#findComment-837244 Share on other sites More sharing options...
ilikephp Posted May 19, 2009 Author Share Posted May 19, 2009 thx a lot, I fixed it. but the only problem that I still have is when I enter all the information, the submit button will appear, and the fieds are becoming empty, how can I keep the information inside the fields? Link to comment https://forums.phpfreaks.com/topic/158742-solved-php-validation/#findComment-837264 Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 thanks a lot, I fixed it. but the only problem that I still have is when I enter all the information, the submit button will appear, and the fieds are becoming empty, how can I keep the information inside the fields? <input type="text" name="name_of" value="<?PHP echo htmlspecialchars($_POST['name_of']); ?>"> Link to comment https://forums.phpfreaks.com/topic/158742-solved-php-validation/#findComment-837266 Share on other sites More sharing options...
Ken2k7 Posted May 19, 2009 Share Posted May 19, 2009 You can combine this line - if (!isset($error['name']) && !isset($error['email']) && !isset($error['password']) && !isset($error['accept'])) into - if (!isset($error['name'], $error['email'], $error['password'], $error['accept'])) Link to comment https://forums.phpfreaks.com/topic/158742-solved-php-validation/#findComment-837269 Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 You can combine this line - if (!isset($error['name']) && !isset($error['email']) && !isset($error['password']) && !isset($error['accept'])) into - if (!isset($error['name'], $error['email'], $error['password'], $error['accept'])) What the OP posted and what you have here are, logically, not the same. Passing multiple variables to isset (joined by commas) checks them all with respect to OR; that is, if any one of the 4 variables passed in here isn't set, the entire statement will return true (because of the logical NOT; isset will return false). Link to comment https://forums.phpfreaks.com/topic/158742-solved-php-validation/#findComment-837276 Share on other sites More sharing options...
ilikephp Posted May 19, 2009 Author Share Posted May 19, 2009 THANKS A LOT MAN!!! it works (Y) Link to comment https://forums.phpfreaks.com/topic/158742-solved-php-validation/#findComment-837285 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.