Loading ...
Sorry, an error occurred while loading the content.
 

RE: [wmlprogramming] Page redirection ------------ my first issue

Expand Messages
  • kenneth gf brown
    your logic and headers need to go ot before ANY other char is sent to the browser.... so ... you need to makesur you have no blank lines infront or your first
    Message 1 of 7 , Apr 30, 2005
      your logic and headers need to go ot before ANY other char is sent
      to the browser.... so ... you need to makesur you have no blank lines
      infront
      or your first <?php tag... and that you logic happes before you close
      that tag or echo anything else out.

      you most likely got a headers already sent error...

      kenneth gf brown
      ceo shadowplay.net


      > -----Original Message-----
      > From: wmlprogramming@yahoogroups.com
      > [mailto:wmlprogramming@yahoogroups.com] On Behalf Of gsm_color
      > Sent: April 30, 2005 09:12
      > To: wmlprogramming@yahoogroups.com
      > Subject: [wmlprogramming] Page redirection ------------ my first issue
      >
      >
      > Hi List ,
      >
      > I'm new to wurfl . I read it well and i got configured wurfl-php
      > correctly in my linux box.
      >
      > I want to do the redirection using wurfl .
      > can i use
      >
      > <?php ( copied from the list )
      > //more code
      >
      > if ($myDevice->browser_is_wap ) {
      > header("Location: index_mobile.php);
      >
      > }else{
      > header("Location: index_pc.php");
      > }
      >
      > //more code
      > ?>
      >
      > with following index.php ( copied from list )
      >
      > <?php
      > // WURFL demo by "Andrea Trasatti" <atrasatti AT users DOT
      > sourceforge DOT net>
      >
      > define('LIB_DIR', '/wurfl_tools/php/');
      > define('CACHE_FILE', '/wurfl_tools/data/cache.php');
      > define('WURFL_USE_CACHE', true); define('WURFL_LOG_FILE',
      > '/wurfl_tools/data/wurfl.log'); define('WURFL_FILE',
      > '/wurfl_tools/xml/wurfl.xml'); define('WURFL_CLASS_FILE',
      > LIB_DIR.'wurfl_class.php'); define('WURFL_PARSER_FILE',
      > LIB_DIR.'wurfl_parser.php'); define('WURFL_PATCH_FILE',
      > '/wurfl_tools/xml/mypatch.xml');
      >
      > require_once(WURFL_CLASS_FILE);
      >
      > require_once('./wurfl_class.php');
      > // creating the WURFL object
      > //$myDevice = new wurfl_class($HTTP_USER_AGENT);
      > $myDevice = new wurfl_class($wurfl, $wurfl_agents);
      > $myDevice->GetDeviceCapabilitiesFromAgent($_SERVER
      > ["HTTP_USER_AGENT"]);
      > if ( $myDevice->browser_is_wap ) {
      > header("Content-Type: text/vnd.wap.wml");
      > echo '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n";
      > ?>
      > <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML
      > 1.1//EN" "http://www.wapforum.org//DTD//wml_1.1.xml">
      > <wml>
      > <card>
      > <p mode="nowrap">
      >
      > <?php
      > if ( $myDevice->getDeviceCapability('gif') ) {
      > echo '<img src="logo.gif" alt="Global TEL" />'."\n";
      > } else {
      > echo '<img src="logo.wbmp" alt="Global TEL" />'."\n<br/>\n";
      > }
      > ?>
      >
      > <a href="index.php">Home</a><br/>
      > </p>
      > </card>
      > </wml>
      >
      > <?php
      > } else {
      > ?>
      > <img src="logo.gif"><br><br>
      > Welcome Web browser.<br>
      > We are sorry, but we are only offering WAP services, at this
      > time.<br> <?php } ?>
      >
      > Actually i'm not a programmer. i'm network engineer. but i have bit
      > knowledge of php. So then , i think i can manage,
      >
      > In this index.php codes , where can i put the above redirection
      > codes ?
      > I tried my own way ,but error message gives , that header() has
      > already in use . bit confused.
      >
      > actually , i need a help from WAP experts in the list ..........plz
      > help
      >
      > Thank u ,
      > Kaine
      >
      >
      >
      >
      >
      >
      >
      >
      > Please read the FAQ before you ask questions:
      > http://www.thewirelessfaq.com
      >
      > Visit http://groups.yahoo.com/group/wmlprogramming for
      > archive and subscription options
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > __________ NOD32 1.1084 (20050430) Information __________
      >
      > This message was checked by NOD32 antivirus system.
      > http://www.nod32.com
      >
      >
    • Andrea Trasatti
      ... Hi, there s an } else { , then the PHP closed a message and then the closing bracket. Change it into something like this: } else { header( Location:
      Message 2 of 7 , May 2, 2005
        Il giorno 30/apr/05, alle 16:11, gsm_color ha scritto:

        > Hi List ,
        >
        > I'm new to wurfl . I read it well and i got configured wurfl-php
        > correctly in my linux box.
        >
        > I want to do the redirection using wurfl .
        > can i use
        >
        > <?php ( copied from the list )
        > //more code
        >
        > if ($myDevice->browser_is_wap ) {
        > header("Location: index_mobile.php);
        >
        > }else{
        > header("Location: index_pc.php");
        > }
        >
        > //more code
        > ?>
        >
        > with following index.php ( copied from list )
        >
        > <?php
        > // WURFL demo by "Andrea Trasatti" <atrasatti AT users DOT
        > sourceforge DOT net>
        >
        > define('LIB_DIR', '/wurfl_tools/php/');
        > define('CACHE_FILE', '/wurfl_tools/data/cache.php');
        > define('WURFL_USE_CACHE', true);
        > define('WURFL_LOG_FILE', '/wurfl_tools/data/wurfl.log');
        > define('WURFL_FILE', '/wurfl_tools/xml/wurfl.xml');
        > define('WURFL_CLASS_FILE', LIB_DIR.'wurfl_class.php');
        > define('WURFL_PARSER_FILE', LIB_DIR.'wurfl_parser.php');
        > define('WURFL_PATCH_FILE', '/wurfl_tools/xml/mypatch.xml');
        >
        > require_once(WURFL_CLASS_FILE);
        >
        > require_once('./wurfl_class.php');
        > // creating the WURFL object
        > //$myDevice = new wurfl_class($HTTP_USER_AGENT);
        > $myDevice = new wurfl_class($wurfl, $wurfl_agents);
        > $myDevice->GetDeviceCapabilitiesFromAgent($_SERVER
        > ["HTTP_USER_AGENT"]);
        > if ( $myDevice->browser_is_wap ) {
        > header("Content-Type: text/vnd.wap.wml");
        > echo '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n";
        > ?>
        > <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML
        > 1.1//EN" "http://www.wapforum.org//DTD//wml_1.1.xml">
        > <wml>
        > <card>
        > <p mode="nowrap">
        >
        > <?php
        > if ( $myDevice->getDeviceCapability('gif') ) {
        > echo '<img src="logo.gif" alt="Global TEL" />'."\n";
        > } else {
        > echo '<img src="logo.wbmp" alt="Global TEL" />'."\n<br/>\n";
        > }
        > ?>
        >
        > <a href="index.php">Home</a><br/>
        > </p>
        > </card>
        > </wml>
        >
        > <?php
        > } else {
        > ?>
        > <img src="logo.gif"><br><br>
        > Welcome Web browser.<br>
        > We are sorry, but we are only offering WAP services, at this time.<br>
        > <?php } ?>
        >
        > Actually i'm not a programmer. i'm network engineer. but i have bit
        > knowledge of php. So then , i think i can manage,
        >
        > In this index.php codes , where can i put the above redirection
        > codes ?
        > I tried my own way ,but error message gives , that header() has
        > already in use . bit confused.
        >
        > actually , i need a help from WAP experts in the list ..........plz
        > help

        Hi, there's an "} else {", then the PHP closed a message and then the
        closing bracket.
        Change it into something like this:
        } else {
        header("Location: index_pc.php");
        } ?>



        This in case you want to redirect PC browsers only, otherwise your
        example was good. The PHP libraries will not send any header, just
        prepare everything, but then it's up to you.

        Don't forget that some OLD devices might have problems with
        redirection. If any user reports that it doesn't get redirected you
        will need to prepare a fake WML page that does redirection. You can
        find help about this on the wireless FAQ (linked in the signature of
        the list).

        - Andrea
      • Kane Wilson
        I changed the codes like this in index.php,
        Message 3 of 7 , May 2, 2005
          I changed the codes like this in index.php,

          <?php
          define("DATADIR", 'data/');
          define("CACHE_FILE", DATADIR."cache.php");
          define("WURFL_USE_CACHE", true);
          define ("WURFL_AUTOLOAD", false);
          define("WURFL_LOG_FILE", DATADIR."wurfl.log");
          define("WURFL_FILE", DATADIR."wurfl.xml");
          define("WURFL_CLASS_FILE", DATADIR."wurfl_class.php");
          define("WURFL_PARSER_FILE", DATADIR."wurfl_parser.php");
          //define("WURFL_PATCH_FILE", DATADIR."mypatch.xml");
          define ("WURFL_AGENT2ID_FILE", DATADIR."agent2id.php4");
          define ("MAX_UA_CACHE", 30);
          require_once(WURFL_CLASS_FILE);
          // creating the WURFL object
          $myDevice = new wurfl_class($wurfl, $wurfl_agents);
          $myDevice->GetDeviceCapabilitiesFromAgent($_SERVER
          ["HTTP_USER_AGENT"]);
          if ( $myDevice->browser_is_wap ) {
          header("Location: index_mo.php");
          ?>
          <?php
          } else {
          header("Location: index_pc.php");
          ?>
          <?php } ?>

          Tested with samsung and motorola mobile phones . We can get contents of index_mo.php via mobile phone and index_pc.php via PC's web Browser.
          But it doesnt work with nokia phones , Error is " file format unknown ".
          Seem to be , there is a problem in index.php codes .
          Plz help this child ................

          Thannk you ,
          Kane.


          Andrea Trasatti <andrea@...> wrote:
          Il giorno 30/apr/05, alle 16:11, gsm_color ha scritto:

          > Hi List ,
          >
          > I'm new to wurfl . I read it well and i got configured wurfl-php
          > correctly in my linux box.
          >
          > I want to do the redirection using wurfl .
          > can i use
          >
          > > //more code
          >
          > if ($myDevice->browser_is_wap ) {
          > header("Location: index_mobile.php);
          >
          > }else{
          > header("Location: index_pc.php");
          > }
          >
          > //more code
          > ?>
          >
          > with following index.php ( copied from list )
          >
          > > // WURFL demo by "Andrea Trasatti" > sourceforge DOT net>
          >
          > define('LIB_DIR', '/wurfl_tools/php/');
          > define('CACHE_FILE', '/wurfl_tools/data/cache.php');
          > define('WURFL_USE_CACHE', true);
          > define('WURFL_LOG_FILE', '/wurfl_tools/data/wurfl.log');
          > define('WURFL_FILE', '/wurfl_tools/xml/wurfl.xml');
          > define('WURFL_CLASS_FILE', LIB_DIR.'wurfl_class.php');
          > define('WURFL_PARSER_FILE', LIB_DIR.'wurfl_parser.php');
          > define('WURFL_PATCH_FILE', '/wurfl_tools/xml/mypatch.xml');
          >
          > require_once(WURFL_CLASS_FILE);
          >
          > require_once('./wurfl_class.php');
          > // creating the WURFL object
          > //$myDevice = new wurfl_class($HTTP_USER_AGENT);
          > $myDevice = new wurfl_class($wurfl, $wurfl_agents);
          > $myDevice->GetDeviceCapabilitiesFromAgent($_SERVER
          > ["HTTP_USER_AGENT"]);
          > if ( $myDevice->browser_is_wap ) {
          > header("Content-Type: text/vnd.wap.wml");
          > echo ''."\n";
          > ?>
          >
          >
          >
          >

          >
          > > if ( $myDevice->getDeviceCapability('gif') ) {
          > echo ''."\n";
          > } else {
          > echo ''."\n
          \n";
          > }
          > ?>
          >
          > Home

          >

          >
          >
          >
          > > } else {
          > ?>
          >


          > Welcome Web browser.

          > We are sorry, but we are only offering WAP services, at this time.

          >
          >
          > Actually i'm not a programmer. i'm network engineer. but i have bit
          > knowledge of php. So then , i think i can manage,
          >
          > In this index.php codes , where can i put the above redirection
          > codes ?
          > I tried my own way ,but error message gives , that header() has
          > already in use . bit confused.
          >
          > actually , i need a help from WAP experts in the list ..........plz
          > help

          Hi, there's an "} else {", then the PHP closed a message and then the
          closing bracket.
          Change it into something like this:
          } else {
          header("Location: index_pc.php");
          } ?>



          This in case you want to redirect PC browsers only, otherwise your
          example was good. The PHP libraries will not send any header, just
          prepare everything, but then it's up to you.

          Don't forget that some OLD devices might have problems with
          redirection. If any user reports that it doesn't get redirected you
          will need to prepare a fake WML page that does redirection. You can
          find help about this on the wireless FAQ (linked in the signature of
          the list).

          - Andrea




          Please read the FAQ before you ask questions: http://www.thewirelessfaq.com

          Visit http://groups.yahoo.com/group/wmlprogramming for archive and subscription options
          Yahoo! Groups Links








          __________________________________________________
          Do You Yahoo!?
          Tired of spam? Yahoo! Mail has the best spam protection around
          http://mail.yahoo.com

          [Non-text portions of this message have been removed]
        • Andrea Trasatti
          ... Does index_mo.php work on the Nokia you re testing? Specifying the exact URL without redirection. What Nokia device are you using? As I had advised in my
          Message 4 of 7 , May 3, 2005
            Il giorno 02/mag/05, alle 20:24, Kane Wilson ha scritto:

            > I changed the codes like this in index.php,
            >
            > <?php
            > define("DATADIR", 'data/');
            > define("CACHE_FILE", DATADIR."cache.php");
            > define("WURFL_USE_CACHE", true);
            > define ("WURFL_AUTOLOAD", false);
            > define("WURFL_LOG_FILE", DATADIR."wurfl.log");
            > define("WURFL_FILE", DATADIR."wurfl.xml");
            > define("WURFL_CLASS_FILE", DATADIR."wurfl_class.php");
            > define("WURFL_PARSER_FILE", DATADIR."wurfl_parser.php");
            > //define("WURFL_PATCH_FILE", DATADIR."mypatch.xml");
            > define ("WURFL_AGENT2ID_FILE", DATADIR."agent2id.php4");
            > define ("MAX_UA_CACHE", 30);
            > require_once(WURFL_CLASS_FILE);
            > // creating the WURFL object
            > $myDevice = new wurfl_class($wurfl, $wurfl_agents);
            > $myDevice->GetDeviceCapabilitiesFromAgent($_SERVER
            > ["HTTP_USER_AGENT"]);
            > if ( $myDevice->browser_is_wap ) {
            > header("Location: index_mo.php");
            > ?>
            > <?php
            > } else {
            > header("Location: index_pc.php");
            > ?>
            > <?php } ?>
            >
            > Tested with samsung and motorola mobile phones . We can get contents
            > of index_mo.php via mobile phone and index_pc.php via PC's web
            > Browser.
            > But it doesnt work with nokia phones , Error is " file format unknown
            > ".
            > Seem to be , there is a problem in index.php codes .
            > Plz help this child ................

            Does index_mo.php work on the Nokia you're testing? Specifying the
            exact URL without redirection. What Nokia device are you using? As I
            had advised in my previous email, you might need to write a WML page
            for redirection for some phones, the header might not work.

            - Andrea
          • Kane Wilson
            Does index_mo.php work on the Nokia you re testing? - No , its works with only Nokia 6230 and Samsung SGH X600. ( I Tested ) But from the other phones , i
            Message 5 of 7 , May 3, 2005
              Does index_mo.php work on the Nokia you're testing? - No , its works with only Nokia 6230 and Samsung SGH X600. ( I Tested )
              But from the other phones , i tested with Nokia 3120 , Nokia 7650 , Noka 6610i also not working.
              I thought , it is broblem with Symbian OS.
              But Nokia 7650 has Symbian. ------ Symbian is not the problem

              Then , i thought , problem with the browser.

              I will submit u , my php codes,

              index.php

              <?php
              define("DATADIR", 'data/');
              define("CACHE_FILE", DATADIR."cache.php");
              define("WURFL_USE_CACHE", true);
              define ("WURFL_AUTOLOAD", false);
              define("WURFL_LOG_FILE", DATADIR."wurfl.log");
              define("WURFL_FILE", DATADIR."wurfl.xml");
              define("WURFL_CLASS_FILE", DATADIR."wurfl_class.php");
              define("WURFL_PARSER_FILE", DATADIR."wurfl_parser.php");
              //define("WURFL_PATCH_FILE", DATADIR."mypatch.xml");
              define ("WURFL_AGENT2ID_FILE", DATADIR."agent2id.php4");
              define ("MAX_UA_CACHE", 30);
              require_once(WURFL_CLASS_FILE);
              // creating the WURFL object
              $myDevice = new wurfl_class($wurfl, $wurfl_agents);
              $myDevice->GetDeviceCapabilitiesFromAgent($_SERVER
              ["HTTP_USER_AGENT"]);
              if ( $myDevice->browser_is_wap ) {
              header("Location:index_mo.php");
              ?>
              <?php
              } else {
              header("Location: index_pc.php");
              ?>
              Welcome to our site,<br>
              You are using a Web browser.<br>
              We are sorry, but we are only offering WAP services, at this
              time.<br>
              <?php } ?>

              index_mo.php

              <?php
              header("Content-type: text/vnd.wap.wml");
              "<?xml version=\"1.0\"?>";
              "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
              . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
              ?>
              <wml>
              <card id="Home" title="Test Page-">
              <p>
              <img src="images/a.gif" align="center" alt="All" width="" height=""/><br/>
              <?php
              $the_date = date("M d Y");
              print $the_date;
              print "<br/>Hellooooo!";
              ?>
              </p>
              </card>
              </wml>

              What could be the wrong ? plz help?

              Thank you,
              Kane.




              Andrea Trasatti <andrea@...> wrote:
              Il giorno 02/mag/05, alle 20:24, Kane Wilson ha scritto:

              > I changed the codes like this in index.php,
              >
              > > define("DATADIR", 'data/');
              > define("CACHE_FILE", DATADIR."cache.php");
              > define("WURFL_USE_CACHE", true);
              > define ("WURFL_AUTOLOAD", false);
              > define("WURFL_LOG_FILE", DATADIR."wurfl.log");
              > define("WURFL_FILE", DATADIR."wurfl.xml");
              > define("WURFL_CLASS_FILE", DATADIR."wurfl_class.php");
              > define("WURFL_PARSER_FILE", DATADIR."wurfl_parser.php");
              > //define("WURFL_PATCH_FILE", DATADIR."mypatch.xml");
              > define ("WURFL_AGENT2ID_FILE", DATADIR."agent2id.php4");
              > define ("MAX_UA_CACHE", 30);
              > require_once(WURFL_CLASS_FILE);
              > // creating the WURFL object
              > $myDevice = new wurfl_class($wurfl, $wurfl_agents);
              > $myDevice->GetDeviceCapabilitiesFromAgent($_SERVER
              > ["HTTP_USER_AGENT"]);
              > if ( $myDevice->browser_is_wap ) {
              > header("Location: index_mo.php");
              > ?>
              > > } else {
              > header("Location: index_pc.php");
              > ?>
              >
              >
              > Tested with samsung and motorola mobile phones . We can get contents
              > of index_mo.php via mobile phone and index_pc.php via PC's web
              > Browser.
              > But it doesnt work with nokia phones , Error is " file format unknown
              > ".
              > Seem to be , there is a problem in index.php codes .
              > Plz help this child ................

              Does index_mo.php work on the Nokia you're testing? Specifying the
              exact URL without redirection. What Nokia device are you using? As I
              had advised in my previous email, you might need to write a WML page
              for redirection for some phones, the header might not work.

              - Andrea




              Please read the FAQ before you ask questions: http://www.thewirelessfaq.com

              Visit http://groups.yahoo.com/group/wmlprogramming for archive and subscription options
              Yahoo! Groups Links








              __________________________________________________
              Do You Yahoo!?
              Tired of spam? Yahoo! Mail has the best spam protection around
              http://mail.yahoo.com

              [Non-text portions of this message have been removed]
            • Andrea Trasatti
              ... Do you have a public URL where we can see it? That will save time to all of us. It might be something with a white line at the beginning, a wrong header,
              Message 6 of 7 , May 4, 2005
                Il giorno 04/mag/05, alle 06:39, Kane Wilson ha scritto:

                > Does index_mo.php work on the Nokia you're testing? - No , its works
                > with only Nokia 6230 and Samsung SGH X600. ( I Tested )
                > But from the other phones , i tested with Nokia 3120 , Nokia 7650 ,
                > Noka 6610i also not working.
                > I thought , it is broblem with Symbian OS.
                > But Nokia 7650 has Symbian. ------ Symbian is not the problem
                >
                > Then , i thought , problem with the browser.
                >
                > I will submit u , my php codes,
                >
                > index.php
                >
                > <?php
                > define("DATADIR", 'data/');
                > define("CACHE_FILE", DATADIR."cache.php");
                > define("WURFL_USE_CACHE", true);
                > define ("WURFL_AUTOLOAD", false);
                > define("WURFL_LOG_FILE", DATADIR."wurfl.log");
                > define("WURFL_FILE", DATADIR."wurfl.xml");
                > define("WURFL_CLASS_FILE", DATADIR."wurfl_class.php");
                > define("WURFL_PARSER_FILE", DATADIR."wurfl_parser.php");
                > //define("WURFL_PATCH_FILE", DATADIR."mypatch.xml");
                > define ("WURFL_AGENT2ID_FILE", DATADIR."agent2id.php4");
                > define ("MAX_UA_CACHE", 30);
                > require_once(WURFL_CLASS_FILE);
                > // creating the WURFL object
                > $myDevice = new wurfl_class($wurfl, $wurfl_agents);
                > $myDevice->GetDeviceCapabilitiesFromAgent($_SERVER
                > ["HTTP_USER_AGENT"]);
                > if ( $myDevice->browser_is_wap ) {
                > header("Location:index_mo.php");
                > ?>
                > <?php
                > } else {
                > header("Location: index_pc.php");
                > ?>
                > Welcome to our site,<br>
                > You are using a Web browser.<br>
                > We are sorry, but we are only offering WAP services, at this
                > time.<br>
                > <?php } ?>
                >
                > index_mo.php
                >
                > <?php
                > header("Content-type: text/vnd.wap.wml");
                > "<?xml version=\"1.0\"?>";
                > "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
                > . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
                > ?>
                > <wml>
                > <card id="Home" title="Test Page-">
                > <p>
                > <img src="images/a.gif" align="center" alt="All" width=""
                > height=""/><br/>
                > <?php
                > $the_date = date("M d Y");
                > print $the_date;
                > print "<br/>Hellooooo!";
                > ?>
                > </p>
                > </card>
                > </wml>
                >
                > What could be the wrong ? plz help?

                Do you have a public URL where we can see it? That will save time to
                all of us. It might be something with a white line at the beginning, a
                wrong header, anything not so easy to see on a post but that will be
                CLEAR when testing on a real URL.

                - Andrea
              Your message has been successfully submitted and would be delivered to recipients shortly.