473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Redirect before header...?

80
Greetings!

I have a php page where I need to redirect the request but for this i need a script loaded first..

Something like:
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2.   function StatusChange(text) {window.status = text; window.status = ''} 
  3. </script>
and later...
Expand|Select|Wrap|Line Numbers
  1. header("Location: javascript: StatusChange ('screen')");
How is this possible when PHP demands the redirect code BEFORE any header?
Oct 8 '09 #1
7 1964
ak1dnar
1,584 Expert 1GB
I hope you are missing something here. May be first you need to understand the difference between the server side scripting language and client side scripting language.
Oct 8 '09 #2
Pheddy
80
@ak1dnar
Ok lets say I need a page to be loaded fully with header and everything, and this page is counting down for a redirect. like on most download sites.. Maybe this where a better way to ask? Please say if im still not understanding.
And forget the JS code..
Oct 8 '09 #3
ak1dnar
1,584 Expert 1GB
Pheddy, What you get on your browser when accessing the url of the web is a rendered HTML output of the php script. So there is no way to call the php header() function from your JS code.

If you need to redirect your page after a certain time, again that is impossible only with PHP. So your best approach for that would be a javascript based redirection with a timer.
Oct 8 '09 #4
Dormilich
8,658 Expert Mod 8TB
@ak1dnar
there’s also the HTML refresh meta tag.
Oct 8 '09 #5
ak1dnar
1,584 Expert 1GB
@Dormilich
Yep, I agree but I guess we need a script based solution for this as he/she has mentioned that
....this page is counting down for a redirect....
So there should be a visible time countdown on the page.
Oct 8 '09 #6
Dormilich
8,658 Expert Mod 8TB
@ak1dnar
when I look at the given code, it is not that obvious to me. the given Javascript function is useless, the PHP code (actually it’s the HTTP code) is wrong. all that remains is a redirect, which can be 100% done in HTML, no Javascript required. although Javascript will make it looking pretty… (you can still do that as addition)

and while I’m at it, a javascript download timer can easily be bypassed… ah, and to start a download, you do not use a redirect (well, at least not most of the time).
Oct 8 '09 #7
TheServant
1,168 Expert 1GB
As Dorm said, PHP is not needed.
If you want a timer and do not want to be limited by something as simple as turning your javascript off: use meta refresh and have a javascript timer totally separate (counting down on its own). Also display a message that if their javascript is off, they will not see the timer, but they have 30secs or what ever.

Basically meta refresh will refresh regardless, provided their browser has not been tweaked, but I think that would defeat the point anyway if it forwards to a download.

I think, Dorm, that this is a system that will have a premium option which will not require waiting, which is why a redirect is desired to start a download.
Oct 8 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Damo | last post by:
Could someone please help me. I am a newbie at PHP. I downloaded formail.php Version 5.0 from Jacks scripts( http://www.dtheatre.com/scripts/ )and changed the required areas to my email address and...
10
by: Bob Garbados | last post by:
forgive my ignorance, as I'm new to php coming from a ms background... If I create a page named redirect.php and it's only content is: <?php header("Location: http://www.google.com"); ?>...
2
by: Sentinel | last post by:
here is the entire thread From: "Kimmo Laine" <eternal.erectionN0.5P@Mgmail.com> Subject: Re: script in body Date: Mon, 20 Jun 2005 17:46:28 +0300 Message-ID:...
2
by: bagsmode | last post by:
Hi, I'm trying to set a session cookie and then redirect, however I get the error: Status: 302 Moved Location: /index.cgi I thought I recall getting an error like this when I first tried...
7
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script...
1
by: Mike P | last post by:
I'm using MamboServer for my site, and have switched from SEF URLs to standard URLs. Of course, I'm indexed everywhere with the SEF urls. I'm trying to write a script, so that users and search...
8
by: Andreas Klemt | last post by:
Hello, I get this error Message "cannot redirect after http headers have been sent" when I do this response.redirect ("home.aspx") How can I find out with vb.net if already a http header has...
5
by: Dave | last post by:
Hi All, Can anyone suggest a reliable solution to php redirect?: header("Location: $redir_url"); if the above times out in $timeout seconds header("Location: $alt_redir_url"); Many thanks,
18
by: Paul Lautman | last post by:
JRough wrote: What do you mean by "redirect the output to Excel"??? Excel isn't a location, it's a spreadsheet program that some (but not all users) will have on their machine. BTW, Location:...
1
by: gnawz | last post by:
Hi guys, I have a couple of php files that perform various tasks. I will use fields in my system and provide code as well I need help as follows: My database contains the fields Category...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.