navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

directing to a "thanks" page with PHP

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> directing to a "thanks" page with PHP
Page: [1]
 
craigj1303

 

Posts: 29
Joined: 5/16/2007
Status: offline

 
directing to a "thanks" page with PHP - 5/1/2008 11:20:05   
Hi

I know nothing about PHP and I am trying to come up with a basic contact form for my website. The form is no problem and I have cut and pasted some PHP which I have tried and tested OK for sending me mail.

The only thing I want to change is what happens after the form is submitted. I want to direct the client to a "thanks for your comments" page where they can then carry on navigating their way around the site. At the moment they just get a message saying "data has been submitted" and would have to use the back button to get back.

Can anyone advise me how to direct them to a different page? Below is the .php file I am using:

<?php
if(isset($_POST['submit'])) {
$to = "xxxxxxxxxx@hotmail.com";
$subject = "Matchday Programmes";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

echo "Data has been submitted to $to!";
mail($to, $subject, $body);
} else {
echo "blarg!";
}
?>

Thanks in advance

Craig
rdouglass

 

Posts: 9137
From: Biddeford, ME USA
Status: offline

 
RE: directing to a "thanks" page with PHP - 5/1/2008 12:21:33   
I use something like this:

echo "<script>window.location=\"/mypage.htm"</script>";

With this tho, JS needs to be enabled.

Hope it helps.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to craigj1303)
craigj1303

 

Posts: 29
Joined: 5/16/2007
Status: offline

 
RE: directing to a "thanks" page with PHP - 5/1/2008 12:41:42   
Hi

When I add that piece of code in place of the existing echo I get this message:

Parse error: syntax error, unexpected $end in /home/fhlinux163/a/anyoldirons.me.uk/user/htdocs/mailer.php on line 17

Can you tell me where I need to add your piece of code and what (if anything) I need to remove from my code to make this work?

(in reply to rdouglass)
rdouglass

 

Posts: 9137
From: Biddeford, ME USA
Status: offline

 
RE: directing to a "thanks" page with PHP - 5/1/2008 12:56:01   
quote:

echo "<script>window.location=\"/mypage.htm"</script>";


Ooops. Sorry, I missed a backslash:

echo "<script>window.location=\"/mypage.htm\"</script>";

That any better?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to rdouglass)
craigj1303

 

Posts: 29
Joined: 5/16/2007
Status: offline

 
RE: directing to a "thanks" page with PHP - 5/1/2008 13:09:29   
brilliant, thanks!

(in reply to rdouglass)
ou812

 

Posts: 1515
Joined: 1/5/2002
From: San Diego
Status: offline

 
RE: directing to a "thanks" page with PHP - 5/1/2008 13:44:21   
If you wanted to use PHP to do this you could use the header command. Something like
header("location:mypage.php");

You can view a bit more here:
http://www.w3schools.com/php/func_http_header.asp
or here:
http://www.php.net/header

_____________________________

-brian

EnterpriseDB: Enterprise-class relational database management system
PostgreSQL: The world's most advanced open source database

(in reply to craigj1303)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> directing to a "thanks" page with PHP
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts