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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.