1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Callling web page from php

Discussion in 'PHP' started by lastmanse, Jun 18, 2011.

  1. lastmanse

    lastmanse New Member

    Joined:
    Jun 18, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    ERP Consultant
    Home Page:
    Does anyone know af an easy way to transfer control to an HTML page from within php code?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,293
    Likes Received:
    365
    Trophy Points:
    83
    Many type of transfer you can achieve. The easiest is the redirect to an html page.
     
  3. lastmanse

    lastmanse New Member

    Joined:
    Jun 18, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    ERP Consultant
    Home Page:
    what is the format of the command to do that? I am brand new to php and can barely spell php...
     
  4. lastmanse

    lastmanse New Member

    Joined:
    Jun 18, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    ERP Consultant
    Home Page:
    AHA - header command!
     
  5. pein87

    pein87 New Member

    Joined:
    Aug 6, 2010
    Messages:
    173
    Likes Received:
    47
    Trophy Points:
    0
    Occupation:
    Web Dev
    Location:
    Limbo
    Technically speaking html doesn't do anything aside from mark up text and media to be presented on the web, css does the presentation and style, javascript does the dynamic content portion and php does the server side backend and data control. You could use ajax to do this and there exist multiple ways to do this which include 3 common methods all of which can be done via php. Theres outputting a meta refresh, javascript and the plan php redirect.

    meta tag refresh

    HTML:
    <meta http-equiv="refresh" content="600;url=www.mysite.com" />
    javascript redirect

    Code:
    <script type="text/javascript">
    function redirect(loc,t,ts = "S")
    {
    if(ts == "M")
    /* minutes add multiply by 1000 for minutes */
    {
    var pageShift = setTimeout(loc,t * 60000);
    }
    if(ts == "MS")
    {
    /* do nothing */
    var pageShift = setTimeout(loc,t);
    }
    if(ts == "H")
    {
    /* use hours */
    var pageShift = setTimeout(loc,t * 3600000);
    }
    if(ts == "S")
    {
    /* seconds */
    var pageShift = setTimeout(loc,t * 1000);
    }
    }
    </script>
    php header

    PHP:
    <?php
    function redirect($url)
    {
    return 
    header("location: " $url);
    }
    redirect("http://www.mysite.com");
    ?>
    the first two can be outputted via a php page using echo or print functions which would redirect to a standard html page, the second one would redirect one page load and function call. Hope this works for you
     
    Last edited: Jun 19, 2011
  6. ManzZup

    ManzZup New Member

    Joined:
    May 9, 2009
    Messages:
    278
    Likes Received:
    43
    Trophy Points:
    0
    Occupation:
    Production Manager:Software @ ZONTEK
    Location:
    Sri Lanka
    Home Page:
    proabably javascript is your choice because php cannot handle anything once it is parsed
    so you need JS + Ajax would be a good solution if it is dynamic :D
     
    Last edited: Jul 3, 2011

Share This Page