php header() redirect issues
-
simy202
- Posts: 1
- Joined: 10 Jan 11
- Location: United Kingdom (UK)
- Trust:
10 Jan 11 9:42 am
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
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
-
faradina
- Posts: 2171
- Joined: 01 Jun 09
- Location: Philippines
- Trust:
11 Jan 11 4:52 am
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.
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.
-
thel.online.ph
- Posts: 109
- Joined: 13 Sep 11
- Location: Philippines
- Trust:
20 Sep 11 5:47 am
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.
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.
