Jump to content

Recommended Posts

I have a form that when properly filled out I would like to send the visitor to a new page. Not an include but a new page that thanks them for filling out the form and then redirects them to the site. I have found that goto is not included in PHP. Most examples I have found have many lines of code and seem so complicated. Is there a way to have  this done simply? All help is greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/70975-send-users-to-thankyou-page/
Share on other sites

Well first you have to have "all that code" to validate that the form is filled out properly... once you have validated it and confirmed that its correct you would then use the header() function as freakstyle said.

 

I have found that almost nothing is "simple - 1 or 2 lines" in php. If you want to make sure that a form is correct, you have to have quite a bit of code to make it happen. I am working on a form right now that has over 30 fields with some being required dependent on the value selected for another field. I am not even done with it yet and it has almost 200 lines of code in it.

 

Any script done correctly will generally be fairly lengthy. I suggest you use this opportunity to learn that "complicated" coding as it is probably not as complicated as it seems.

Thanks freakstyle and chronister,

 

      My problem is I'm not to familiar with php. If I am reading correctly I need to end the session and destroy the existing header??? This comes at a place in the code when all conditions have been met. It's part of a "if" "else" statement. I don't know how to break out of the php page and return to the html site.

<?php

if($all_fields_validated=='Yes')
{
  header('Location:http://yoursite.com/thankyoupage.php')
}
else
{
  echo 'Please fix the errors before proceeding';
}

?>

 

You don't need to destroy the session and header, you just need to call the header() at the right time. See example above... It's a very simplistic example.

 

Nate

 

Thanks Chronister

 

Below is the end of the code. Some parts are commented out for testing. I still recieve an error about sending the headers:

 

  if($valid == true) {

          //Sending Email to form owner

/*

          $pfw_header = "From: $email\n"

            . "Reply-To: $email\n";

          $pfw_subject = "From Join ML Form";

          $pfw_email_to = "nobody@nowhere.non";

          $pfw_message = "Visitor's IP: $pfw_ip\n"

          . "name: $name\n"

          . "lastname: $lastname\n"

          . "company: $company\n"

          . "title: $title\n"

          . "address1: $address1\n"

          . "address2: $address2\n"

          . "city: $city\n"

          . "state: $state\n"

          . "zip: $zip\n"

          . "email: $email\n"

          . "interests: $interests\n"

          . "other_interest: $other_interests\n"

          . "End of information";

          @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header );

*/

header("Location: http://ourloca.tion/form_completed.php");

 

  }

else {

    echo "<center><a href=\"javascript:history.go(-1)\">Sorry, the code you entered was invalid<br>Go back to form</center>";

 

  }

}

 

?>

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.