•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 373,930 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,272 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1025 | Replies: 4
![]() |
•
•
Join Date: Dec 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
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://whatever.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, 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?
thanks in advance,
Gym
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://whatever.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, 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?
thanks in advance,
Gym
•
•
Join Date: Feb 2007
Location: St. Vincent and the Grenadines, Caribbean
Posts: 906
Reputation:
Rep Power: 3
Solved Threads: 38
you can put an echo right before it to check if, first of all, that line of code is ever reached. (Of course this echo will cause the header() to throw an error if they are indeed reached, but it's just testing).
Last edited by scru : Dec 20th, 2007 at 4:53 pm.
Half and a half meck a whole, and I donned it a hundrid purcent
•
•
Join Date: Jul 2007
Posts: 94
Reputation:
Rep Power: 2
Solved Threads: 2
This is a really common problem that occurs when using php to redirect users. The header must be at the top of the page (first thing the browser reads). So i would suggest using the following code instead.
echo("<script>location.href = 'http://whatever.com/thankyou.php';</script>");
This just echos out a javascript redirect. It is a lot easier and more reliable than PHP.
echo("<script>location.href = 'http://whatever.com/thankyou.php';</script>");
This just echos out a javascript redirect. It is a lot easier and more reliable than PHP.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,041
Reputation:
Rep Power: 8
Solved Threads: 227
•
•
•
•
This is a really common problem that occurs when using php to redirect users. The header must be at the top of the page (first thing the browser reads).
Wrong. The header can be anywhere in the script. The only thing is, you shouldn't output anything before the header function(not even a html tag).
header("location: http://whatever.com/thankyou.php"); is just as good as echo("<script>location.href = 'http://whatever.com/thankyou.php';</script>");P.S. header is comparatively faster since its a php function, where as in the other case, it should first 'echo' the redirect script.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Other Threads in the PHP Forum
- Previous Thread: how rapidshare do its progressbar?
- Next Thread: Question about creating Consent Forms



Linear Mode