Zubrag.com
May 21, 2012, 01:26:07 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Redirect After Download  (Read 6790 times)
pangaea
Newbie
*
Posts: 1


« on: January 10, 2009, 10:25:59 am »

I haven't seen this problem discussed in the forum, although I may have missed it.

Our website requires that the visitor register with us before downloading the file. After clicking on the Register button, the download.php script runs. That is working fine and the file is downloaded. However, the browser stays on the registration page. We want them to immediately go to our home page, or at least back to the original download page. We added the following command at the end of the download.php script:

header("Location: http://www.mysite.com")  //fake address, of course

but nothing happens. We certainly don't want the visitor to repeat clicking on the Register button. Are the earlier header commands the problem? No error message appears, as it does when we use this redirection command after page content appears.

Any thoughts on how to redirect the viewer? We don't want to use JavaScript, since many users may have it turned off. We could add some html code at the end to show a page with a button that the visitor clicks to continue. But that is really an unnecessary and annoying extra step for the visitor.

Thanks for your help.

Logged
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #1 on: February 27, 2009, 08:30:43 pm »

Code:
If your still working on this, let me know in a reply.

Generic reply:

the PHP function header() can only be used at the top of a file, eg:
[code]<?php header("Location: http://google.co.uk");echo 'hello';
Would work, it would redirect, but you would not see the 'hello'.
[code<?php echo 'hello'; header("Location: http://google.co.uk");[/code]
Would not work, and should say a error relating to 'header information already sent'. You can't even have a small space, or blank line, that is interpreted as a character.

In short for header() to work, make sure nothing in the HTML comes first, if you do get that error, view the source of the document, and see what comes up before the error does.
Logged

calypso
Newbie
*
Posts: 1


« Reply #2 on: December 17, 2010, 12:07:32 am »

Hi I have this same problem. I'd like to redirect somewhere after downloading the file. Did you find a solution?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC