PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 6th, 2012, 05:28 PM
odp odp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 60 odp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 46 m 3 sec
Reputation Power: 2
Help with redirect or alternative solution

I have this form a user fills out.
The data is sent to a script that processes the data and creates a file stored on the server.

The page redirect to a thank you message that is being shown and the file automatically be server.

As it is now the proccessing file redirects with
PHP Code:
 header(locationthanks.php); 


The thanks.php file is shown as long as I dont have the file served to the user - using this code

PHP Code:
<?php

header
('Content-type: application/powerpoint');

header('Content-Disposition: attachment; filename="downloaded.pptx"');

readfile('presentation.pptx');

?>


When I add this code to thanks.php the page will not be displayed.
I tried to use the header redirect method in thanks.php to redirect to a file called download.php but that will not work since the function will create a new header and bypass the html content of thanks.php

I guess the reason why thanks.php is not shown when above code is present is because a new header is created and the html content therefor bypassed?

What should I do?

Reply With Quote
  #2  
Old October 6th, 2012, 06:12 PM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,886 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 3 Days 8 h 22 m 27 sec
Reputation Power: 581
What precedes the headers? There can be nothing, not even whitespace, before the headers or they will be ignored.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Reply With Quote
  #3  
Old October 6th, 2012, 06:18 PM
odp odp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 60 odp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 46 m 3 sec
Reputation Power: 2
Quote:
Originally Posted by gw1500se
What precedes the headers? There can be nothing, not even whitespace, before the headers or they will be ignored.


right now nothing

PHP Code:
<?php
header
('Content-type: application/powerpoint');
header('Content-Disposition: attachment; filename="downloaded.pptx"');
readfile('02presentation.pptx');
?>


<!DOCTYPE html>
<html>
<head>.....

Reply With Quote
  #4  
Old October 6th, 2012, 06:28 PM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,886 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 3 Days 8 h 22 m 27 sec
Reputation Power: 581
Seems like that should work then. Did you check the httpd log for any PHP errors (assuming you have errors turned on)?

Reply With Quote
  #5  
Old October 6th, 2012, 06:38 PM
odp odp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 60 odp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 46 m 3 sec
Reputation Power: 2
Quote:
Originally Posted by gw1500se
Seems like that should work then. Did you check the httpd log for any PHP errors (assuming you have errors turned on)?


there is no relating errors

Reply With Quote
  #6  
Old October 6th, 2012, 06:47 PM
odp odp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 60 odp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 46 m 3 sec
Reputation Power: 2
Well, as I mention the file is being served for download when thanks.php is loaded. It is the html content that is not being displayed

Reply With Quote
  #7  
Old October 6th, 2012, 07:11 PM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,886 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 3 Days 8 h 22 m 27 sec
Reputation Power: 581
I don't think you can get both. You either download the file or output the page.

Reply With Quote
  #8  
Old October 6th, 2012, 07:38 PM
odp odp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 60 odp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 46 m 3 sec
Reputation Power: 2
Quote:
Originally Posted by gw1500se
I don't think you can get both. You either download the file or output the page.


Then how would I alternativly do this?

Reply With Quote
  #9  
Old October 6th, 2012, 08:05 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,947 E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 10 h 55 m 23 sec
Reputation Power: 7053
On your thanks.php use JavaScript to redirect the user to download.php.

You can't serve a download and output HTML in the same request.

You can send a Location header and output HTML in the same request, but most browsers will not show the HTML.
__________________
PHP FAQ
How to program a basic, secure login system using PHP
Connect with me on LinkedIn


Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Help with redirect or alternative solution

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap