Jump to content

header location and form repopulate


amarkabove

Recommended Posts

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;

}

 

Link to comment
https://forums.phpfreaks.com/topic/94948-header-location-and-form-repopulate/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.