1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Calculating Area with PHP

By

1 of 3

Collecting User Information
 <head> 
 <title>Calculate Area</title> 
 </head> 
 <body> 
 <h2>Calculate Area</h2> 
 <form action = "<?php echo $_SERVER['PHP_SELF']; ?>" 
 method = "GET"> 
 Width: <input type = "text" name = "width" size=4> 
 <br/> 
 Length: <input type = "text" name = "length" size=4> <br> 
 <input type="hidden" name="calc" value ="yes"> 
 <input type = "submit" name = "Calculate"/> 
 </form> 
 </body> 
 </html> 
 
Above is the HTML that we use to collect the length and width of our rectangle from the user. We are using PHP_SELF to send the information back to this page when submitted. We are sending three variables. Our variables are length, width, and calc. The calc variable is hidden, and will be used in the next step of our script.
Related Video
How to Create a PHP Calendar
Basic PHP Syntax
  1. About.com
  2. Technology
  3. PHP / MySQL
  4. Step By Steps
  5. How to Create a PHP Program to Calculate Area

©2014 About.com. All rights reserved.