1. Computing & Technology

Discuss in my forum

Calculating Area with PHP

By , About.com Guide

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.

©2012 About.com. All rights reserved.

A part of The New York Times Company.