Guys I am having problem in redirecting to home page of site after registration of member at signup page. Once visitor fill registration form and click on submit script add that user to database successfully and also send email to member about registration notification but after that I have this code that is not working: header("Location: http://www.yahoo.com"); This is not working, I don't know what happened. Same script/code was working earlier. Please help me how to redirect users to another page of successful signup. Thank you GCS
Any error messages generated? Any output to the screen before you send this? You could do what vb does and show a screen saying wait a few seconds and then use a meta refresh instead.
I have used same code many times but never error occur, here is error Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxxxx/public_html/testtable.php:8) I also tried to redirect by two files. call.php testtable.php Now when I run testtable.php in browser it gives above error. Earlier I was redirecting in same testtable.php (call.php code) but later I think I should try redirecting by separate file but that also fails. Any help please "After adding member details in database how to redirect visitor to other page like confirmation page etc"? Before redirection a proper php code is executed that adds details in database and send email to user. Up to this (sending email to member) script is working fine and very next line is redirection line that is not working. GCS
Is there any kind of hosting problem. As I said earlier I used this code many times and did not face such kind of problem. But unusual thing is this time I used CuteFTP to edit and upload files. Instead of editing php files in 1st page or any other editor I open file from my local drive and upload instantly. That is a little bit easy. GCS
<?php require "call.php"; ?> <table> <tr> <td> This is a test line. </td> </tr> </table> Code (markup): By outputting HTML BEFORE you call up the header function, makes the browser think he is about to read a HTML file. Like aaron said.
The way it is working now is the correct way. It is possible your prior server was using some sort of output buffering and compression which delayed the output and gave time for the headers to be sent first, but it is a better habit for headers to /always/ come before content.
u should put ob_start as a frst statement in ur page and after issuing location() function u should use exit() let me know if it works
Same code was working on different host. I am also finding another host to experiment same code there and it should work. Octalsystem, I will try you method and will update if that works. GCS
you already sent information , headers, tables etc .. you can only redirect header: location when no other stuff has been displayed to the webpage .. once it starts writing the page. nuffin.
Bullshit. Use ob_start - either in the php-script itself, or set the environment variable in php.ini. Lets you use headers whenever you want to, regardless of what you've put out of HTML earlier. Might be a performance issue, of course, but that's irrelevant to the fact that it is completely possible to do.
Guys Thank you for all helping comments. I agree what you people are saying but the most important thing is I run this script very well on other host without any change. So I feel there is some thing configuration matter that is hosting provider dependent. I am finding alternate host so I may check this. GCS
Sounds like your last host had output buffering turned on in the php.ini . It wouldn't output anything until the entire script runs. As a experienced php programmer, I know that if you output anything before the header location redirect then it will throw an error. You can do the ob_start or turn on output buffering in the php.ini file and not throw out this error. Send a message to your web host to turn this on for you or help you setup the php.ini in the root folder for your website.
Thanks for your helping post. I already have php.ini. Can you tell me command line for php.ini for on_start turning on? GCS
Search you php.ini for "output_buffering" and set it to "on" or a value, like this: output_buffering = 4096 You might have to uncomment the line, if it's not activated already.
in the beginning of the file just add this .. <?php ob_start(); ?> bla bla bla ... <? header("Location: http://www.yahoo.com"); ?> bla bla bla <?php ob_end_flush(); ?>
Guys Today I moved to new host and this problem is solved automatically without any change in script. Thank you for all people who replied and helped me to understand this problem. GCS
A suggestion for the future: when it comes down to redirects use Javascript and/or .htaccess redirects. They are much better than PHP redirects. Regards, Dennis M.