Need a new web host or having a problem with a script? Tips and advice on the best way to design, build and maintain your most valuable asset - your website!

php header() redirect issues

simy202
Posts: 1
Joined: 10 Jan 11
Trust:

php header() redirect issues

I am having a problem with URL redirection using a mail submission form.

The form is working and sends the mail successfully, the problem lies when I try to redirect the user to a thankyou.php page using header('Location: http://xxxxx.com/thankyou.php');

When the form is filled in and submitted, the mailform.php page executes but the redirection does not occur, I just get the blank page mailform.php.

Searching the web over my syntax for the header() script looks correct, PHP redirection is there anyway to debug this to see what exactly is occurring? Do I need to do anything on the server side in order to allow this function to work properly?

Thx
  • 0
faradina
Posts: 2171
Joined: 01 Jun 09
Trust:
Hi simy202,

Which autoresponder service are you using? Also, can we have the actual URL of your thank you page? if you do not want to post it here you can send it to us through the contact form at our support page.
  • 0
thel.online.ph
Posts: 109
Joined: 13 Sep 11
Trust:
Hi,

Redirect before any echo or print function, <doctype>, or <html> tag. This will also help keep the logic and design separate. Make sure there is no output before you redirect. And I would suggest using the following code:

echo("<script>location.href = 'http://xxxxx.com/thankyou.php';</script>");

instead of:

header('Location: http://xxxxx.com/thankyou.php');

This just echos out a javascript redirect. It is a lot easier and more reliable than PHP.
  • 0

This topic was started on Jan 10, 2011 and has been closed due to inactivity. If you want to discuss this topic further, please create a new forum topic.

cron