|
|
|
|
![]() ![]() |
Jan 6 2006, 07:12 PM
Post
#1
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 17 Joined: 6-January 06 Member No.: 16,687 |
hey ppl, u seem to have real gud knowledge about php, i just wanted a little help...i designed this website, but i want that if i click on certain page, it should open for some few seconds and then browser should automatically redirect me to some other page....i tried this with header() function but i couldnt do the wait n redirect part, ...
so somebody plz help.... -thanx in advance! |
|
|
|
Jan 7 2006, 09:55 AM
Post
#2
|
|
|
Incest is a game the whole family can play. ![]() Group: [MODERATOR] Posts: 1,223 Joined: 11-February 05 From: Heaven Member No.: 3,709 |
I don't think that this is possible with php but you can do it with javascript. This code goes in the <head> tag:
HTML <script type="text/javascript">
function goOnwards() { window.location = "http://bla.com"; } setTimeout("goOnwards()", 3000); </script> <!-- Provide an alternative for those without javascript --> <noscript> <meta http-equiv="refresh" content="3; url=http://bla.com"> </noscript> |
|
|
|
Jan 9 2006, 10:11 AM
Post
#3
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 130 Joined: 21-December 05 Member No.: 15,990 |
My answer in other topic:
http://www.trap17.com/forums/problem-page-...ect-t32062.html I think that Header function better... <meta refresh>! Code like CODE <meta http-equiv="refresh" content="5;url=http://www.mysite.com/nextpage.html"> can be stopped by Escape button pressing!!! I think that this code will help U. CODE <?php header("Location: http://www.example.com/"); /* Redirect browser */ /* Make sure that code below does not get executed when we redirect. */ exit; ?> View full description about Header function at http://php.rinet.ru/manual/ru/function.header.php with some examples. |
|
|
|
Jan 30 2006, 04:45 AM
Post
#4
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: Members Posts: 40 Joined: 29-January 06 Member No.: 17,841 |
I don't think header function makes any sense as you cannot send headers once you have started your content. It is helpful for redirection if you want to do something without sending any output to browser and then redirect (like one file for doing operations and redirect to other to display UI). But once you have displayed some UI, it would have already committed the headers to browser. So, when you try to redirect, it gives error "headers already sent". |
|
|
|
Jan 30 2006, 04:28 PM
Post
#5
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 873 Joined: 30-July 04 Member No.: 246 |
Hmm, this topic is pretty old. But anyway, in response to kvkv...
Of course the headers need to be sent prior to any output. The headers inform the client of information required to ensure the client knows what to do with the data, and they must come before the data to which they are related. This is not specific to PHP (or Apache or any other web server), but rather to the hypertext transfer protocol, the protocol you are almost definately using to access webpages (see the specification for version 1.1 - the current standard - for details). For example, let's say there are two files the client requests - 'page.html', a webpage, and 'image.jpg', an image. We can associate both files with their types due to their extensions (and, in this case, their full file names), but a web browser is not going to be able to differentiate one from the other unless the server tells it which is which via the 'Content-Type' header, which would be something like 'text/html' for the webpage and 'image/jpeg' for the image. Although some clients do identify files based on their file extension, that's not the way the HTTP works, and is just one of the reasons header information must accompany every packet of data sent from a HTTP server to the client. Without the header information, the client is not going to know what the data is or what to do with it, as well as other critical information (in which case most clients treat the data as 'text/plain', which is why you will sometimes find the contents images or other binary files are being printed to the screen as text). Anyway, my overdrawn, pointless lecture slash rant is done |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 12th October 2008 - 03:32 PM |