simple formm & $_POST

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

    simple formm & $_POST

    I have this form:

    <form action="http://www.XXXXXXX.com/form.php" method="post"
    name="form1" target="_blank" id="form1">
    <label>Nome &nbsp;&nbsp;&nb sp;&nbsp;&nbsp;
    <input name="<b>name</b>" type="text" maxlength="45" />
    </label>
    <p>
    <label>Last
    <input name="last name" type="text" dir="ltr" maxlength="45" />
    </label>
    </p>

    now, i have made this php script just to echo the value in "name" and
    "last" but it doesn't work:

    <?php
    print("$_POST['name']");
    print("thanks, see you soon");
    ?>

    what's the error?

  • Rami Elomaa

    #2
    Re: simple formm &amp; $_POST

    vinnie kirjoitti:
    I have this form:
    >
    <form action="http://www.XXXXXXX.com/form.php" method="post"
    name="form1" target="_blank" id="form1">
    <label>Nome &nbsp;&nbsp;&nb sp;&nbsp;&nbsp;
    <input name="<b>name</b>" type="text" maxlength="45" />
    Remove the <b></bfrom input name.
    </label>
    <p>
    <label>Last
    <input name="last name" type="text" dir="ltr" maxlength="45" />
    </label>
    </p>
    >
    now, i have made this php script just to echo the value in "name" and
    "last" but it doesn't work:
    >
    <?php
    print("$_POST['name']");
    print("thanks, see you soon");
    ?>
    >
    what's the error?
    >
    You can test what was posted with
    print_r($_POST) ;

    It's often very helpful in debugging the input data.

    --
    Rami.Elomaa@gma il.com

    "Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
    usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze

    Comment

    • countach

      #3
      Re: simple formm &amp; $_POST

      En las nuevas, el vinnie escribió:
      I have this form:
      >
      <form action="http://www.XXXXXXX.com/form.php" method="post"
      name="form1" target="_blank" id="form1">
      <label>Nome &nbsp;&nbsp;&nb sp;&nbsp;&nbsp;
      <input name="<b>name</b>" type="text" maxlength="45" />
      </label>
      <p>
      <label>Last
      <input name="last name" type="text" dir="ltr" maxlength="45" />
      </label>
      </p>
      >
      now, i have made this php script just to echo the value in "name" and
      "last" but it doesn't work:
      >
      <?php
      print("$_POST['name']");
      print("thanks, see you soon");
      >>
      >
      what's the error?

      <input name="<b>name</b>"

      should be

      <input name="name"


      Comment

      • vinnie

        #4
        Re: simple formm &amp; $_POST

        >
        You can test what was posted with
        print_r($_POST) ;
        >
        It's often very helpful in debugging the input data.
        >
        --
        Rami.Elo...@gma il.com
        i did, but this is what i get:
        <<
        Array(form1(nam e))
        thanks, see you soon
        >>
        While i was expecting the name that the user has typed in. Is there
        anything missing?

        Comment

        • Erwin Moller

          #5
          Re: simple formm &amp; $_POST

          vinnie wrote:
          >>
          >You can test what was posted with
          >print_r($_POST );
          >>
          >It's often very helpful in debugging the input data.
          >>
          >--
          >Rami.Elo...@gm ail.com
          >
          i did, but this is what i get:
          <<
          Array(form1(nam e))
          thanks, see you soon
          >>>
          >
          While i was expecting the name that the user has typed in. Is there
          anything missing?
          Hi Vinnie

          print_r need <pretags, like this:

          echo "<pre>";
          print_r($_POST) ;
          echo "</pre>";

          for output that you can actually read being human. :)

          Regards,
          Erwin Moller

          Comment

          • Erwin Moller

            #6
            Re: simple formm &amp; $_POST

            vinnie wrote:
            I have this form:
            >
            <form action="http://www.XXXXXXX.com/form.php" method="post"
            name="form1" target="_blank" id="form1">
            <label>Nome &nbsp;&nbsp;&nb sp;&nbsp;&nbsp;
            <input name="<b>name</b>" type="text" maxlength="45" />
            </label>
            <p>
            <label>Last
            <input name="last name" type="text" dir="ltr" maxlength="45" />
            </label>
            </p>
            >
            now, i have made this php script just to echo the value in "name" and
            "last" but it doesn't work:
            >
            <?php
            print("$_POST['name']");
            Besides the namingproblem (boldtags), another thing:
            You use:
            print("$_POST['name']");

            Why do you use the "" around the $_POST["name"] ?
            simply do:
            echo $_POST['name'];

            You said you are a novice. My advise would be NOT to use
            variablesubstit ution in strings untill you understand what is happening.

            eg:
            $name="vinnie";
            echo "Your name is $name";

            Works just fine, but it is excactly the same as:
            echo "Your name is".$name;

            The above example wasn't very tricky, but this one is worse:
            $name[0]["firstname"] = "vinnie";
            echo "Your name is $name[0]["firstname"]";

            which will result in an error (because of the "" used as stringdelimmite r
            and in the name-array.).

            Easier is just to assemble your string using . as glue:
            echo "Your name is ".$name[0]["firstname"];


            Regards,
            Erwin Moller
            print("thanks, see you soon");
            ?>
            >
            what's the error?

            Comment

            Working...