Page 1 of 1

php redirection or links

Posted: Sun Sep 30, 2007 9:21 am
by grantg
Hello. I have created a new site, which has only had the one page uploaded live for a small test - http://www.discountgardencentre.co.uk/contact. The forum passes the data to mailer.php - which then echos "Thank you for your comments to xyz@abc.co.uk" on screen. That is the only output the code gives. It does work, as the emails are sent to our inbox. But, the problem is, it takes the user to a dead page, with no redirection back to the main site or even a link to get there. This is the code for the php file, I would like the file to redirect after 5 seconds, or display a link to say something to the effect of "Click here to return to http://www.discountgardencentre.co.ukwww.discountgardencentre.co.uk.

Code: Select all

<?php

if(!$url) { $url = 'http://www.discountgardencentre.co.uk'; } ?>


if(isset($_POST['submit'])) {

$to = "sales@cupargardencentre.co.uk";
$subject = "OnlineGardenCentre.uk.com Query";
$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 "Thank you for your comments to $to!";
mail($to, $subject, $body);
<?php echo($url); ?>

} else {

echo "Sorry, the e-mail function failed. Please try again or e-mail us directly at sales@cupargardencentre.co.uk";

}
?>



Thank you for your help!

Posted: Sun Sep 30, 2007 10:11 am
by superdezign
You could use a meta refresh in the <head> of the page.

Code: Select all

<meta http-equiv="refresh" content="2;url=http://www.domain.tld/">
If you just want to display a link, then I have absolutely no clue why you even need to ask us how to.

Posted: Sun Sep 30, 2007 10:20 am
by anjanesh
You can use the META refresh though it must within the head block.

Code: Select all

<meta http-equiv="refresh" content="5;url=http://example.com/index.php">
or using JavaScript to redirect. window.location = '';