Question from beginner

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Antoine Mérieux

    Question from beginner

    Hello,
    I try to use php, but I have problem with forms.

    I have a file named test.php like that:
    <FORM ACTION="test.ph p" METHOD="POST">
    type your name, then submit :
    <INPUT TYPE=text NAME=name>
    <INPUT TYPE=submit VALUE="Submit">
    </FORM>
    <P>
    your name is
    <?php
    echo "$name";
    ?>

    And I have this error:
    Notice: Undefined variable: name in c:\program
    files\easyphp1-8\www\epc\test. php on line 9

    What's wrong

    Thank you.
    Antoine

  • Virginner

    #2
    Re: Question from beginner

    "Antoine Mérieux" <no_mail_adress @yahoo.com> wrote in message
    news:44932dbd$0 $9606$636a55ce@ news.free.fr...
    | Hello,
    | I try to use php, but I have problem with forms.
    |
    | I have a file named test.php like that:
    | <FORM ACTION="test.ph p" METHOD="POST">
    | type your name, then submit :
    | <INPUT TYPE=text NAME=name>
    | <INPUT TYPE=submit VALUE="Submit">
    | </FORM>
    | <P>
    | your name is
    | <?php
    | echo "$name";
    | ?>
    |
    | And I have this error:
    | Notice: Undefined variable: name in c:\program
    | files\easyphp1-8\www\epc\test. php on line 9
    |

    echo $name

    D.


    Comment

    • Antoine Mérieux

      #3
      Re: Question from beginner

      Virginner a écrit :[color=blue]
      > "Antoine Mérieux" <no_mail_adress @yahoo.com> wrote in message
      > news:44932dbd$0 $9606$636a55ce@ news.free.fr...
      > | Hello,
      > | I try to use php, but I have problem with forms.
      > |
      > | I have a file named test.php like that:
      > | <FORM ACTION="test.ph p" METHOD="POST">
      > | type your name, then submit :
      > | <INPUT TYPE=text NAME=name>
      > | <INPUT TYPE=submit VALUE="Submit">
      > | </FORM>
      > | <P>
      > | your name is
      > | <?php
      > | echo "$name";
      > | ?>
      > |
      > | And I have this error:
      > | Notice: Undefined variable: name in c:\program
      > | files\easyphp1-8\www\epc\test. php on line 9
      > |
      >
      > echo $name
      >
      > D.
      >
      >[/color]
      It's wrong again.
      It's very bizarre!

      Comment

      • David Haynes

        #4
        Re: Question from beginner

        Antoine Mérieux wrote:[color=blue]
        > Hello,
        > I try to use php, but I have problem with forms.
        >
        > I have a file named test.php like that:
        > <FORM ACTION="test.ph p" METHOD="POST">
        > type your name, then submit :
        > <INPUT TYPE=text NAME=name>
        > <INPUT TYPE=submit VALUE="Submit">
        > </FORM>
        > <P>
        > your name is
        > <?php
        > echo "$name";
        > ?>
        >
        > And I have this error:
        > Notice: Undefined variable: name in c:\program
        > files\easyphp1-8\www\epc\test. php on line 9
        >
        > What's wrong
        >
        > Thank you.
        > Antoine
        >[/color]
        Antoine,
        There are really three things wrong with the code you have sent us:
        1. it needs to be contained within an <html> tag set (i.e. valid html)
        2. the values to the attributes should be in quotes
        3. the value of the input tag 'name' is contained in $_POST['name'], not
        $name.

        Here is your code reworked so that it does what you expect:
        <html>
        <head></head>
        <body>
        <form action="test.ph p" method="POST">
        type your name, then submit:
        <input type="text" name="name">
        <input type="submit" value="Submit">
        </form>
        <p>
        your name is <?php echo $_POST['name'];?>
        </body>
        </html>

        -david-
        p.s. I use lowercase because I don't like code SHOUTING at me ;-)

        Comment

        • AlexVN

          #5
          Re: Question from beginner

          Antoine,

          There are a little bit more information about why to use $_POST['name']
          instead of $name:


          Sincerely,
          Alexander
          COCOL88 adalah platform slot online modern dengan performa stabil, pilihan game lengkap, dan akses cepat. Cocok untuk pengguna yang mengutamakan kenyamanan dan kualitas


          Comment

          • Antoine Mérieux

            #6
            Re: Question from beginner

            AlexVN a écrit :[color=blue]
            > Antoine,
            >
            > There are a little bit more information about why to use $_POST['name']
            > instead of $name:
            > http://php.net/register_globals
            >
            > Sincerely,
            > Alexander
            > http://www.alexatnet.com/
            >[/color]
            Thank you very much. I think it's the good way.
            But now it's late, time to bed, I'll see it tomorrow.
            Tomorrow is another day
            bye

            Comment

            • Antoine Mérieux

              #7
              Re: Question from beginner

              Thank you David.
              It's the solution
              Superb

              Comment

              Working...