SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Jun 2001
    Location
    Malaysia
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP function to "auto-return" user to page

    guys...

    i'm looking for a function in PHP where after a specific period... it returns you to the mainpage.

    Kinda like after I post this.. there's a slight delay and you're returned to the main forum.

    What's the function, it's syntax and an example of it's usage?
    Any other considerations I need to take into account?

    Thanks a bill!

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This has to happen at the client (not at the server). So you can just use a meta refresh tag inside the <head></head> tags in your html.

    For example:
    Code:
    <html>
    <head>
    <META HTTP-EQUIV="Refresh" CONTENT="10"; URL=http://www.domain.com/index.php">
    <title>foo</title>
    <body>
    bar
    </body>
    </html>
    I think the CONTECT= is expressed as seconds.

  3. #3
    SitePoint Addict
    Join Date
    Jun 2001
    Location
    Malaysia
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    umm.. ok. questions.

    the command:
    <html>
    <head>
    <META HTTP-EQUIV="Refresh" CONTENT="10"; URL=http://www.domain.com/index.php">
    <title>foo</title>
    <body>
    bar
    </body>
    </html>

    is there supposed to be a opening " after 'URL=' ?
    so the title reads..

    <META HTTP-EQUIV="Refresh" CONTENT="10"; URL="http://www.domain.com/index.php">

    and is it CONTENT or CONNECT?

    Anyway, I tried the above, with CONTENT, and the pages seem to be trying to return to the page i specified in the URL. However, I keep on getting the pop-up error msg "the page cannot be refreshed w.out resending info...click retry to send again". what gives? on that page, I have a link to the URL i want to go to. it's all localhost, as I am running Apache on this PC and not uploading anything yet.

    Here's my code so far:

    <?php session_start(); ?>

    <HTML>
    <HEAD>
    <META HTTP-EQUIV="Refresh" CONTENT="4"; URL="pdc_emp mainpage.php">

    <A HREF="pdc_emp mainpage.php" > Click here to return to the main page<P></A>
    <LINK REL="stylesheet" HREF="C:\pdc_emp.css" TYPE="text/css">
    </HEAD>

    Am using Sessions, and a style sheet, which is stored independent as a single file in C:\. The <A HREF link works correctly when I click it (no error msgs), but the <META tag does not...

  4. #4
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Culpa mia. This is how it I should have written that tag

    <META HTTP-EQUIV="Refresh" CONTENT="10; URL=http://www.domain.com/index.php">

    Note I have removed the " after 10. The content string is:
    "10; URL=http://www.domain.com/index.php"

    I hope that works

  5. #5
    SitePoint Addict
    Join Date
    Jun 2001
    Location
    Malaysia
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks FreakySid!

    It works just fine now....

    See ya in other posts!


    Oooh.. hold on a sec! One more quest.. how about if I want the page to display a "you will be redirected to <URL> in X seconds"... where X will display a count-down....

    Can I do that *easily* in PHP or is that something left to JAVA? Do let me know how!

    thank KEW!
    Last edited by infinitium; Jul 2, 2001 at 17:44.

  6. #6
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't do it in PHP, because it's a server-side language. You'd need to use Javascript or Java. I'm not sure exactly how you'd do it, but check any of the free JS sites...they would have the code for sure.

  7. #7
    You want what? By when?? Milamber's Avatar
    Join Date
    Jan 2001
    Location
    California
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why not just make a very small animated gif that counts down the numbers 1 a second? it's be much easier and simpler than any java trick that can (even when it is as simple as that) throw some browsers.
    -Jeff Minard | jrm.cc - Battlefield 2 Stats


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •