PDA

View Full Version : adding a redirect code to php script



AWS
10-25-2006, 03:27 PM
Hi,

I have a php script (got from vodahost) to my root directory at http://www.pantryhamper.ie which is working fine but as the message that you view when published is clashing with the websites coluors(background & text) then I wish to clone a web page and place my message here and automatically redirect to this page when online form is submitted.

Can I add a redirect code to my existing php script so as to allow this while keeping the form working in every other aspect?

If yes then where do I add this code and what exact piece of code do I need?

The php scrip that I have already in use is as follows.........

<HTML>
<HEAD>
<TITLE>SUCESSFULLY PROCESSED YOUR ORDER/ENQUIRY</TITLE>
</HEAD>
<BODY>
<H2>thank you for your order/enquiry to pantry hamper.a member of pantry hamper will reply as soon as possible!</H2>
<?PHP
$email=$HTTP_POST_VARS[email];
$mailto="info@pantryhamper.ie";
$mailsubj="Online Order/Enquiry Contact Form";
$mailhead="from:$email\n";
reset($HTTP_POST_VARS);
$mailbody="Values submitted from website form:\n";
while(list($key,$val)=each($HTTP_POST_VARS))
{
$mailbody.="$key:$val\n";
}
mail($mailto,$mailsubj,$mailbody,$mailhead);
?>
</BODY>
</HTML>

Thanks,
Liam

navaldesign
10-25-2006, 05:00 PM
If i understand well:

Solution 1: combine a custom made Thankyou page with the script: Create a page as you like it. In your case you must save it as "order_inframe", Make it the same dimensions of your i-frame.


Now, the script must become as follows:




<?PHP
$email=$HTTP_POST_VARS[email];
$mailto="info@pantryhamper.ie";
$mailsubj="Online Order/Enquiry Contact Form";
$mailhead="from:$email\n";
reset($HTTP_POST_VARS);
$mailbody="Values submitted from website form:\n";
while(list($key,$val)=each($HTTP_POST_VARS))
{
$mailbody.="$key:$val\n";
}
mail($mailto,$mailsubj,$mailbody,$mailhead);
?>



Copy this code. Go back in your page (order_inframe) and click on View, Pahe HTML
Click on" Inside Body" and paste the code in there. Also, go in Page Properties, and where you see "File extension" set it to php. Save the page and publish it. It will take the place of your script (order_inframe.php) but it will have the layout that you have created.

Have a look at http://www.vodahost.com/vodatalk/forms/7233-how-upload-file-using-form.html

It os the same method, only the script is different, as the one in this link will also upload files if necessary.

Solution 2: redirect the script after submission to a thankyou page:

Create a "thankyou_page" as you like it. Save it as "thankyou_page" and publish it normally.
Modify your script as follows:




<?PHP
$email=$HTTP_POST_VARS[email];
$mailto="info@pantryhamper.ie";
$mailsubj="Online Order/Enquiry Contact Form";
$mailhead="from:$email\n";
reset($HTTP_POST_VARS);
$mailbody="Values submitted from website form:\n";
while(list($key,$val)=each($HTTP_POST_VARS))
{
$mailbody.="$key:$val\n";
}
mail($mailto,$mailsubj,$mailbody,$mailhead);
header("Location: thankyou_page.html");
?>



replace your script with this one and you are done.

AWS
10-25-2006, 05:08 PM
Thanks Navaldesign,I will follow these instructions to the letter.Thanks again.

Best,
Liam

AWS
10-25-2006, 05:41 PM
Hi Naval design,

I followed solution 2 as you have laid out above but keep getting the following error message when submitting......

Warning: Cannot modify header information - headers already sent by (output started at /home2/pfjywgyr/public_html/order_inframe.php:2) in /home2/pfjywgyr/public_html/order_inframe.php on line 14


The following is the php script used.....


<?PHP
$email=$HTTP_POST_VARS[email];
$mailto="info@pantryhamper.ie";
$mailsubj="Online Order/Enquiry Contact Form";
$mailhead="from:$email\n";
reset($HTTP_POST_VARS);
$mailbody="Values submitted from website form:\n";
while(list($key,$val)=each($HTTP_POST_VARS))
{
$mailbody.="$key:$val\n";
}
mail($mailto,$mailsubj,$mailbody,$mailhead);
header("Location:http://www.pantryhamper.ie/thank_you.html");
?>


Did I go wrong in the header? should I have typed the full url or what you had typed out?

There was a space between the : and thankyou_page of which I removed.....should I have done this?

Sorry for taking more of your time on this but will you write out php script exactly as I should use for the page (now published) titled thank_you for http://www.pantryhamper.ie

AWS
10-25-2006, 06:58 PM
Hi Naveldesign,

Scratch my last post as all working fine.

The space was the problem and caused the error.

Thanks for all your help and talk to you soon.

Best Regards,
Liam.