Jump to content

marb

Members
  • Posts

    3
  • Joined

  • Last visited

marb's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hi, I've created an html form to increase information in an Array, but each time a press the form button, the value of the array is reset. How can I do to set the value in the array? There's my example: <html> <body> <form method="post"> <p>First Name: <input type="text" name="firstname"/> <p>Age: <input type="text" name="age"/> <p>City: <input type="text" name="city"/> <input type="submit" value="Send" /></p> </form> </body> <?php $people = array ( array("Joe",0,0), array("Jack",0,0), array("John",0,0), array("Mary",0,0) ); $i=0; while ($i<=4) { if (isset($_POST["firstname"]) and isset($_POST["age"]) and isset($_POST["city"])) { if ($_POST["firstname"]=="Joe") { $people[0][1]=$_POST["age"]; $people[0][2]=$_POST["city"]; } if ($_POST["firstname"]=="Jack") { $people[1][1]=$_POST["age"]; $people[1][2]=$_POST["city"]; } if ($_POST["firstname"]=="John") { $people[2][1]=$_POST["age"]; $people[2][2]=$_POST["city"]; } if ($_POST["firstname"]=="Mary") { $people[3][1]=$_POST["age"]; $people[3][2]=$_POST["city"]; } } $i++; } echo("<table><table border='1'>"); echo("<tr><th colspan='3'>People</th></tr>"); echo("<tr><th>Name</th><th>Age</th><th>City</th></tr>"); for ($i=0;$i<=3;$i++) { echo("<tr><td align=center>".$people[$i][0]."</td><td align=center>".$people[$i][1]."</td><td align=center>".$people[$i][2]."</td></tr>"); } ?> </table> </html>
  2. marb

    Form button action

    Thank you. I've tried it before, but I didn't put the " " by the variable submit.
  3. marb

    Form button action

    Hi, I'm new here and I'm learning PHP. I'm trying to do a little script to print a message after push an HTML button, but the message appears before I push the button. When I have a textbox, I can control that with the instruction" if isset($_Post[text var])", but without the textbox I can't do it. Help me please. Here is the sample: <html> <body> <form " method="post"> <input type="submit" value="Msg" name="submit" /></p> </form> </body> </html> <?php echo "Hello"; ?>
×
×
  • Create New...