PDA

View Full Version : How do you relate form #1 with thankyou page #1 and form #2 with thank you page #2?



Lflagg
08-03-2007, 09:34 PM
i have 2 different forms with 2 different thank you pages.
how do u relate form #1 with thank you page #1 and form #2 with thank you page #2? they have the same "submit" button at the end. should the submit button be different? when i did a test online of my form#2 it went to thank you page #1.
thanks!

Watdaflip
08-03-2007, 10:37 PM
Its not the submit button that has to change its the "action" of the forms.

Form 1's action needs to be set to "thank_you_1.php" (or whatever you want to call it)

Form 2's action needs to be set to "thank_you_2.php" (again, or whatever you want it to be)


Now it could also be the script itself. I'm assuming your form is setup like this... You have the actual form where people enter data (say you call it form.html). And then you have the action (the page that processes it), say you call that action.php. And the final page that people end up on is thankyou.html.

If you changed the action.php for the second form, then its the script that you need to edit. Towards the end of the script it will probably say header("location: thank_you.php"); (or thank_you.html)

Its that line that needs to be edited on the second action script for the second form

Lflagg
08-04-2007, 01:45 AM
OK, so if my form page is called www.whatever.com/employment.hmtl (http://www.whatever.com/employment.hmtl) how should i call then the "action/thank you" page so it can be related to it?
same for the page where clients submit info: www.whatever.com/contact_us.html (http://www.whatever.com/contact_us.html).

is there when i get confused...
thanks! :)

Watdaflip
08-04-2007, 02:50 AM
Set the action on employment.html to be a file like employment_action.php
and for contact_us.html to be contact_action.php, and just copy and paste the php script onto both the *_action.php pages.

And the last step is an assumption so you may not have to do it.
I'm assuming you are using the a basic default email script you got from the tutorial, in which case there will be a line of code like
header("location: somefile.php"); toward the bottom of the script. You just have to change that to the success/thank you pages for each form. Create one for the employment form and one for the contact form (unless you want to use the same one with a generic message). In any case make sure that is a valid and correct file to redirect to ( header("location.."); is a php redirect, fyi).

Lflagg
08-06-2007, 08:13 PM
the generic php code i got from the tutorial doesn't include the header("location: somefile.php"); part... should i add it myself and where and what its supposed to say?
thanks!

navaldesign
08-06-2007, 09:35 PM
There is no need for it, if you use a BV page and include the script in it.

If, instead, you do NOT embedd the script in a page, but you simply upload it as standalone, the script should become:

<?
$mailto = "exampleemail@example.com";
$email = $HTTP_POST_VARS['email'];
if ($email == "") {
$email = $mailto;
}
$mailsubj = "Type your mail subject here";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form :\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
header("location: somefile.php"); //Can be also somefile.html
?>

If you go this way, the script has to be opened in Notepad, edited, then use the Save As command, select ALL files, and save it as "action.php". Then you need to upload it on your server using FTP or File Manager.

The "somefile.php" or "somefile.html" is your thank you page.

If you want to use the same script but different thank you pages, use this script:

<?
$redirect= $_POST['redirect'];
$mailto = "exampleemail@example.com";
$email = $_POST['email'];
if ($email == "") {
$email = $mailto;
}
$mailsubj = "Type your mail subject here";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form :\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
header("location: $redirect");
?>

Include, in each form of yours, a HIDDEN field. Name the hidden field "redirect" . For each form, This hidden field should have, as value, the URL of the thank you page related to the specific form.

This way you can have one script, and as many thank you pages as you want, each one related to a specific form.