zulubanshee Posted May 14, 2008 Share Posted May 14, 2008 I'm doing a slight modification of the punbb bulletin board software. Specifically I've added a required edit field (called 'tag') to the registration page. Well, when the information if filled out properly, there is no problem. I have the script set up to catch anyone who leaves the tag empty. The user is prompted to use the Go Back link or hit the back button. BUT...when they fill out the tag field and hit the Submit button, the field is still being shown as empty. Is there something generic I'm overlooking...or should I post the code? Quote Link to comment https://forums.phpfreaks.com/topic/105605-solved-form-validation-and-resubmission-problem/ Share on other sites More sharing options...
nloding Posted May 14, 2008 Share Posted May 14, 2008 Probably wanna post the code sections for the form and the form processing. Quote Link to comment https://forums.phpfreaks.com/topic/105605-solved-form-validation-and-resubmission-problem/#findComment-541015 Share on other sites More sharing options...
zulubanshee Posted May 14, 2008 Author Share Posted May 14, 2008 Just to clear exactly what happens: The 'onsubmit' javascript is disabled in this functionality for some reason (otherwise it gives an popup prompting to fill in the fields). The tags are passed as an array and processed, ie one may submit more than one tag in the field. The 'message' function terminates the process and outputs that message immediately in html. It also includes the javascript link to Go Back Again, this works ok if it's done right the first time; it's when you hit the back button etc... register.php if (!isset($_POST['form_sent'])) { <form id="register" method="post" action="register.php?action=register" onsubmit="this.register.disabled=true;if(process_form(this)){return true;}else{this.register.disabled=false;return false;}"> <input type="hidden" name="form_sent" value="1" /> <label>'Username'</label><br /> <input type="text" name="req_username" size="25" maxlength="25" /><br /></label> <label>'Tags'</label><br /> <input type="text" name="req_arr_tags" size="40" maxlength="200" /><br /></label> <input type="submit" name="register" value="Register" /> } if (isset($_POST['form_sent'])) { if (strlen($username) < 2) message('Username too short'); } else if($arr_tags = 1) { $arr_tags = $_POST['req_arr_tags']; if($arr_tags == '') { message('You must enter at least one tag so others can connect to you.'); } } //otherwise enter the username and tags into the database Quote Link to comment https://forums.phpfreaks.com/topic/105605-solved-form-validation-and-resubmission-problem/#findComment-541066 Share on other sites More sharing options...
zulubanshee Posted May 14, 2008 Author Share Posted May 14, 2008 oops. never mind. I figured it out. I had the if statement in the wrong place in the script. I would have had to post a huge chunk of code in order for anyone to figure that one out. Quote Link to comment https://forums.phpfreaks.com/topic/105605-solved-form-validation-and-resubmission-problem/#findComment-541071 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.