Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> php header() function help needed, automatic re-direct
ashish_m_k
post 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!
Go to the top of the page
 
+Quote Post
electriic ink
post Jan 7 2006, 09:55 AM
Post #2


Incest is a game the whole family can play.
Group Icon

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>
Go to the top of the page
 
+Quote Post
DeveloperX
post 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.
Go to the top of the page
 
+Quote Post
kvkv
post 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".
Go to the top of the page
 
+Quote Post
Spectre
post 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 smile.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Getting List Of Directories And Files Using Php(6)
  2. How To Use A Link To Call Function In Php?(8)
  3. Include File.php?id=something(13)
  4. Php Header Problem(11)
  5. Automatic Login Using Curl(1)
  6. How Good Is This Data Cleaning Function?(2)
  7. The Extract() Function(6)
  8. [php] Header Function(2)
  9. [php](simple) Using Functions To Combine Values In A Form(2)
  10. Ipetsite Related Programming Help Needed(0)
  11. Mail() Clone(5)
  12. The Best Zip Function(1)
  13. Creatting A Playlist Through Php(5)
  14. Php Explode Function Help(4)
  15. How To Check If Fsockopen Function Is Enabled?(2)
  1. Wamp Packages Needed To Test Scripts(1)
  2. Arrays Outside A Function(3)
  3. Slaed Cms(2)
  4. Php Code(15)
  5. Php Code Needed(5)
  6. Looking For Command Line Based Sql Modification(1)
  7. Php Code Needed Iii(10)
  8. Tools Needed!(9)
  9. Endif function?(6)
  10. Admin Page(4)
  11. Tutorial Needed?!(11)
  12. PHP Function To Add Previous and Next Page Feature(5)
  13. Xampp How Can I Generate "automatic Start Sites"(7)


 



- Lo-Fi Version Time is now: 12th October 2008 - 03:32 PM