/    Sign up×
Community /Pin to ProfileBookmark

PHP redirection

hi! i was wondering how to use php for automatic redirection to a page on the website

basically, the visitors first fill out a form, and the form gets e-mailed to me and takes the visitors to a page saying “Thank you for filling out the form”.

This form e-mail thing is done using php … and i was wondering how to incorporate a redirection code in the following code so that afer submitting a form, the user goes to the page thats says “thank you …” and redirects the user back in 3 seconds to the a different page

[code=php]<?PHP
$to = “[email protected]”;
$subject = “Submit a FORM”;
$headers = “From: Form Mailer”;
$forward = 0;
$location = “”;

$date = date (“l, F jS, Y”);
$time = date (“h:i A”);

$msg = “Below is the result of your feedback form. It was submitted on $date at $time.nn”;

if ($_SERVER[‘REQUEST_METHOD’] == “POST”) {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) .” : “. $value . “n”;
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) .” : “. $value . “n”;
}
}

mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header (“Location:$location”);
}
else {
echo “Thank you for submitting your review.”;
}

?>[/code]

THANX A LOT FOR HELPING!!

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@frupMar 11.2006 — you use HTML not PHP

<meta http-equiv="refresh" content="5;URL=newpage.php">

the 5; is the timer
Copy linkTweet thisAlerts:
@welshMar 11.2006 — change:
[code=php]
else {
echo "Thank you for submitting your review.";
}
[/code]

to
[code=php]
else {
echo "Thank you for submitting your review.";
echo '<meta http-equiv="refresh" content="5;URL=newpage.php">';
}
[/code]
Copy linkTweet thisAlerts:
@LakshauthorMar 11.2006 — hi, thanx a lot welsh .... i really appreciate it ... WORKS PERFECTLY NOW!
Copy linkTweet thisAlerts:
@tubaplaya76Mar 11.2006 — couldn't it also be done like this, through php?

[code=php]<?php
header("Location: http://www.example.com/");
?>[/code]


?
Copy linkTweet thisAlerts:
@welshMar 11.2006 — yes, but that would be right after the script finished executing, not waiting the say the 3 seconds he required.
Copy linkTweet thisAlerts:
@tubaplaya76Mar 12.2006 — yes, but that would be right after the script finished executing, not waiting the say the 3 seconds he required.[/QUOTE]

Oh okay. I must have missed that part of the post. My apologies.
Copy linkTweet thisAlerts:
@bokehMar 12.2006 — Don't use a META element for this. Use a header redirect as suggested by [URL=http://w3.org/]W3C[/URL] [code=php]header("Refresh: $seconds; URL="$location"");[/code]
×

Success!

Help @Laksh spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...