variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sentinel

    variables

    i would like to send a variable to the next paage i am about to load bu
    not using post

    eg. index2.php?a=0& b=1&c=2


    how do i send them and how can i read them?



    thanks


    --
    What's the point in running when the light at the end of the tunnel iz
    just another train...
  • Alvaro G Vicario

    #2
    Re: variables

    *** Sentinel wrote/escribió (Fri, 17 Jun 2005 09:55:59 +0000 (UTC)):[color=blue]
    > i would like to send a variable to the next paage i am about to load bu
    > not using post
    >
    > eg. index2.php?a=0& b=1&c=2
    >
    >
    > how do i send them and how can i read them?[/color]

    I suggest that you get a basic PHP tutorial rather than trying to figure
    out how things work, it'll be less frustrating.

    About your question, you can generate HTML just typing it outside the PHP
    tags:

    <?php

    // This is PHP

    ?> This is HTML

    Or you can use echo or print statements:

    <?php

    echo 'This is HTML dynamically generated from PHP';

    ?>

    You read URL parameters from the $_GET associative array:

    echo 'Param a=' . $_GET['a'];

    --
    -- Álvaro G. Vicario - Burgos, Spain
    -- http://bits.demogracia.com - Mi sitio sobre programación web
    -- Don't e-mail me your questions, post them to the group
    --

    Comment

    • douglass_davis@earthlink.net

      #3
      Re: variables

      You can use POST or GET to "send variables" to the next page.

      GET is what you have listed in your question.

      eg. index2.php?a=0& b=1&c=2

      POST is when you use a form. From the PHP web site:

      When a form is submitted to a PHP script, the information from that
      form is automatically made available to the script. There are many ways
      to access this information, for example:

      Example 12-8. A simple HTML form

      <form action="foo.php " method="post">
      Name: <input type="text" name="username" /><br />
      Email: <input type="text" name="email" /><br />
      <input type="submit" name="submit" value="Submit me!" />
      </form>

      You may get the POST 'username' variable (from the form above) by using
      these
      $_POST['username'];
      $_REQUEST['username'];

      You may retrieve the GET variable 'a' (from index2.php?a=0& b=1&c=2)
      by the using these
      $_POST['a'];
      $_REQUEST['a'];


      --
      PHP stuff :


      Comment

      • Colin McKinnon

        #4
        Re: variables

        douglass_davis@ earthlink.net wrote:
        [color=blue]
        > You can use POST or GET to "send variables" to the next page.[/color]
        <snip>[color=blue]
        > From the PHP web site:[/color]
        <snip>[color=blue]
        > You may retrieve the GET variable 'a' (from index2.php?a=0& b=1&c=2)
        > by the using these
        > $_POST['a'];
        > $_REQUEST['a'];
        >[/color]

        Really? The PHP website said that?
        It should have said:

        You may retrieve the GET variable 'a' (from index2.php?a=0& b=1&c=2)
        by the using these
        $_GET['a'];
        $_REQUEST['a'];


        C.

        Comment

        • www.douglassdavis.com

          #5
          Re: variables

          sorry... you are correct. that was a quick copying and pasting mistake!

          Comment

          • Sentinel

            #6
            Re: variables

            Colin McKinnon 17.6.2005 15:21:11
            <d8uimv$58b$1$8 300dec7@news.de mon.co.uk>
            colin.deletethi s@andthis.mms3. com comp.lang.php Colin
            [color=blue]
            > douglass_davis@ earthlink.net wrote:
            >[color=green]
            > > You can use POST or GET to "send variables" to the next page.[/color]
            > <snip>[color=green]
            > > From the PHP web site:[/color]
            > <snip>[color=green]
            > > You may retrieve the GET variable 'a' (from index2.php?a=0& b=1&c=2)
            > > by the using these
            > > $_POST['a'];
            > > $_REQUEST['a'];
            > >[/color]
            >
            > Really? The PHP website said that?
            > It should have said:
            >
            > You may retrieve the GET variable 'a' (from index2.php?a=0& b=1&c=2)
            > by the using these
            > $_GET['a'];
            > $_REQUEST['a'];
            >
            >
            > C.[/color]

            thanks to both

            --
            What's the point in running when the light at the end of the tunnel iz
            just another train...

            Comment

            Working...