1.

Solve : A redirect?

Answer»

Hi, i have this code at the bottom of a php file that sends an email about form data as some of you know.

I want it to redirect to an url after the form data has been sent. At the moment all I can get it to do is bring up a new page with the echo wording "Thankyou for contacting us.. blah blah". I want it to go to say:

www.mysite.com/index.html for example.

Code: [Select]// if the redirect option is set: redirect them
if ($redirect) {
   header("Location: $redirect");
   exit;
} else {
   echo "THANK you for contacting us. We will contact you shortly!\n";
   echo "<br><br>\n";
   exit;
}
What do i need to change for it to work?

I'm PRETTY sure it's in the line: header("Location: $redirect");

Thanks.Please help? I need to get this done:(

Thanks.try this, it *should* work.

Code: [Select]// if the redirect option is set: redirect them
if ($redirect) {
   header("Location: $redirect");
   exit;
} else {
   echo "<body onload='javascript:location=http://www.yahoo.com'>\n";
   echo "Thank you for contacting us. We will contact you shortly!<br>\n";
   echo "If you are not redirected, <a href='http://slashdot.org'>click here</a>.<br>\n";
   exit;
}
umm, it doesn't lol.. It just stays on a white page with the text "Thank you for contacting us. We will contact you shortly!
If you are not redirected, click here." where click here is the link you set. It doesn't redirect to yahoo.com:( or anywhere for that matter!AH got it to work:)

all i needed to do was change where you had written: Code: [Select]   echo "<body onload='javascript:location=http://www.yahoo.com'>\n";

to Code: [Select]   echo "<body onload=javascript:location='http://www.yahoo.com'>\n";

If you can't see the difference, its the first '  I have MOVED it from before the word "javascript" to infront of the url "http://www.yahoo.com".

Cheers michael;)



Discussion

No Comment Found