I am trying to learn this but I am so not logical and I'm lost as all hell.
Anyway I'll just copy paste what I've already put on yahoo answers.
Can you help me figure this out this php?
So far this is what I have and I'm lost on what else to do. I have a test over it tomorrow so I really just want to kind of get the homework done and study my homework for the test. I'm not catching this stuff so well, I have one more assignment after this that I'm sure I'll be asking for help on. Anyway, This is my assignment---
Create a form that asks the user for the length and width of a rectangle. When the user presses "Submit" (or whatever you call it) the page should call a php page in the hmwk10 folder that will calculate the following:
* The perimeter of the rectangle (two times the length plus width)
* The area of the rectangle (length times the width)
* The length of the diagonal (square root of length times length plus width times width)
This is what I have in my php file:
<?php
if($_POST['form_submit'] == 'TRUE')
{
$width = 0;
$length = 0;
$perimeter = 0;
$area = 0;
$diag = 0;
if(is_numeric($_POST['width']))
{
$width = $_POST['width'];
}
if(is_numeric($_POST['length']))
{
$length = $_POST['length'];
echo $output;
?>
This is what I have in my html file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml…
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>PHP Sample</title>
</head>
<body>
<form action="process.php" method="post">
<div>
<input name="width" type="text" value="0"/>
<input name="length" type="text" value="0"/>
<input name="form_submit" type="hidden" value="TRUE"/>
<input type="submit" value="Calculate"/>
</div>
</form>
<hr />
<p><a href="http://validator.w3.org/check/refe… this page</a></p>
</body>
</html>
I'm confused. Someone helped with what I have so far and I'm still lost. Why am I putting zero after the width and lenght variables?
Also for the perimeter variable, shouldn't I have it say
$perimeter = (2 * $length) + $width;
and area
$area = $length * $width;
and for length of diaganoal
not sure how to do the length of the diagonal (square root of length times length plus width times width)
I really am lost on the logics of it all like what goes in php, what goes in html..bleh