note 31512 added to tutorial.forms
| From: | mlone at mn dot rr dot com | Date: | Thu, 24 Apr 2003 15:59:40 +0000 |
| Subject: | note 31512 added to tutorial.forms | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47033@lists.php.net to get a copy of this message | ||
The $_Post['name'] can be assigned to another variable if you are doing simple
mathematics.
For example:
<html>
<head><title></title></head>
<body>
<form action="add.php" method="post">
<input type="text" name="num1" size="24">+
<input type="text" name="num2" size="24"><br>
<input type="submit" value="Add">
</body>
</html>
Now, you can compute using add.php using the following:
<html>
<head><title>Adding 2 numbers</title></html>
<body>
<?php
$value1 = $_POST["num1"];
$value2 = $_POST["num2"];
$sum = $value1 + $value2;
?>
<table border="1">
<tr>
<td>
<?php echo "$value1 + $value2 ="; ?>
</td>
<td bgcolor="#CCDDFF">
<?php echo "$sum"; ?>
</td>
</tr>
</table>
</body>
</html>
As you can see, $_POST["num1"]; and $_POST["num2"]; has been assigned to the
variables $value1 and $value2 respectively. The rest of the code is self explanatory.
--
http://www.php.net/manual/en/tutorial.forms.php
http://master.php.net/manage/user-notes.php?action=edit+31512
http://master.php.net/manage/user-notes.php?action=delete+31512
http://master.php.net/manage/user-notes.php?action=reject+31512