note 31512 deleted from tutorial.forms by philip

From: Date: Thu, 01 May 2003 06:38:08 +0000
Subject: note 31512 deleted from tutorial.forms by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-47326@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.

« previous php.notes (#47326) next »