shane85 Posted November 7, 2010 Share Posted November 7, 2010 hey guys. Right now upon form submission, I do an error check that puts all the errors into an array, then will display them at the top of the form. What I want to do though is break up the array, and be able to give each error msg in its indivdual table row in the html. Right now, my coding is if($lname == '') { $errmsg_arr[] = 'You must enter your last name'; $errflag = true; } if($email == '') { $errmsg_arr[] = 'You must enter your email address'; $errflag = true; } if($city == '') { $errmsg_arr[] = 'You must enter your city'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: signup_artist.php"); exit(); } thats in form2.php form 1.php has the following snipet of code <?php if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) { echo '<ul class="err">'; foreach($_SESSION['ERRMSG_ARR'] as $msg) { echo '<li>',$msg,'</li>'; } echo '</ul>'; unset($_SESSION['ERRMSG_ARR']); } ?> so basically would I would like to be able to do is identify each error as for instane $fname_error $lname_error etc and then load them into my html appropriately, as opposed to just an array listing them Quote Link to comment https://forums.phpfreaks.com/topic/217996-help-with-giving-error-codes-on-form-submission/ Share on other sites More sharing options...
radar Posted November 7, 2010 Share Posted November 7, 2010 You would basically do this exactly how you are currently. If you want the error message to show up next to the fname box you'd just do a simple if statement to display that... but to do that, you'd need to change your if statements above as well that generate the errors. if ($_SESSION['ERRMSG_ARR']['f_name'] != '') { echo $_SESSION['ERRMSG_ARR']['f_name']; } Quote Link to comment https://forums.phpfreaks.com/topic/217996-help-with-giving-error-codes-on-form-submission/#findComment-1131342 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.