amarkabove Posted March 7, 2008 Share Posted March 7, 2008 first problem is that when i submit the form and there are errors, when the form is reloaded there is nothing in the form fields. everything that was entered is gone. second thing is that when the form is successfully submitted i am unable to redirect to another page. if ($_POST['_submit_check']) { if ($form_errors = validate_form()){ show_form($form_errors); }else{ process_form(); header('location= jointhankyou.html'); } }else { show_form(); } function show_form($errors = '') { if ($errors) { $error_text = '<div id="left_side"><h3> These fields are required.<br>'; $error_text .= implode('<br>',$errors); $error_text .= '</h3></div>'; }else{ $error_text = ''; } echo $error_text; } function validate_form() { $errors = array(); if (! strlen(trim($_POST['CompanyName']))) { $errors[] = 'Please enter your Company Name'; } if (! strlen(trim($_POST['CompanyContact']))) { $errors[] = 'Please enter the Company Contact'; } if (! strlen(trim($_POST['PhoneNumber']))) { $errors[] = 'Please enter the Contact Phone Number'; } return $errors; } Quote Link to comment 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.