can any one help me with this script I am just gettin started with PHP

I am trying to create an calculation script that would
calculate the

Constant: PI = 3.1415926535
Radius, area, and circumference of a circle .

This is what I have dont so far but just cant seem to get it working

can some one tell me what i am doing wrong

<html>
<head>
<title>
Calculation Form
</title>
</head>
<body>

<form method="post" action="circumference.php">

<p>Rad:<input type="text" name="radius=" size=10></p>


<p><input type="submit" name="submit" value="calculate"></p>
</form>

</body>
</html>


PHP Script

<? php

if (!isset($_POST)) {
echo '<form action="' . $_SERVER . '" . method="post">' .
'<input type="text" name="radius" />' .
'<input type="submit" name="submit" value="Calculate" />' .
'</form>';
} else {
$circumference = M_PI * $_POST * 2;
$area = M_PI * pow($_POST, 2);
echo 'Circumference = ' . $circumference . ' units<br />';
echo 'Area = ' . $area . ' sq. units<br />';
}

?>
<html>
<head>
<title></title>
</head>

<body>
<p> This result of the is : <? echo "$result" ; ?></p>
</body>
</html>

Thanks

Recommended Answers

All 2 Replies

What error message(s) are you getting?

<p> This result of the is : <? echo "$result" ; ?></p>

Where did you define $result? And it is also better to use <?php than <?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.