trying to create the front end to a script that will calculate the area and circumference of a circle.
(1)HTML form that will contain three input fields and a submit buttom
(2) will have only one text input field that input field is radius
(3)Create a calculation script with the following data:

Variables: Readius, Area, and Circumference
Constant: Pi = 3.1415926535

this is the script i have written so far

(HTML Form)
<html>
<head>
<title>
Calculation Form
</title>
</head>
<body>
<form method="post action="circumference.php">
<p>Radius:<input type="text" name="val1" size=10></p>
<p><input type="text" name="val2" size=10></p>
<p><input type="text" name="val3" size=10></p>
<p><input type="submit" name="submit" value="calculate"></p>
</form>

</body>
</html>

(PHP Calculation Script)
<?
if (($POST[val1] == "") || ($POST[val2] == "") || ($_POST[calc] =="")) {
// more code goes here
}
header("Location: http://127.0.0.1/findcirc.html"); exit;

if ($POST[calc]== "add") (
$result = $
POST[val1] + $_POST[val2];

) else if ($POST[calc] == "variables") {
$result= $
POST[val1] - $_POST[val2];

} else if ($POST[calc]) == "radius") {
$result = $
POST[val1] * $_POST[val2];

} else if ($POST[calc] == "cirumference") {
$result = $
POST[val1] / $_POST[val2];
}
?>

Thnk

    You should do a little more work on this script. As it is, it's hard to believe you've even run it. The HTML won't work right because of a missing quote (and all attribute values should be quoted as well). The PHP should give you several error warnings, e.g. for the missing quotes around the array keys.

    You say you want only one input field, but the code you posted has three. You also say you want to do some geometric calculations, but the code shows only some elementary arithmetic.

    Also: use long open tags; use the predefined constant M_PI; check into using an array for your input fields (if you're going to have more than one); where does $_POST['calc'] come from?

      Nothing to apologize for (except maybe not using the forum's code tags). Just use the manual, write and run some more code to see what happens, and go from there. Do that then ask more questions here and you'll get plenty of help.

      Here's some code that might help some:

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

      That's pretty simple (no validation or error-checking, for example) but maybe it'll help you see where you might go with your own code.

        thanks I appreciate it, like I stated before I am just getting started, the next problem I'm facing with is that I download PhP Mysql and Apache server the problem that I am having is that I can't get the scripts or PHP page to work I guess I did not config it right. I dont have a sever so I am usin my computer as the server so i can view my work in the brownser. I did learn about Wamp server which made it easier to download. but i still cant get to view the php pages I have created.

        this is what i have done so far with the httpd. configuration(/ My Email/ and IP) I am not sure if I need to config the rest of it meaning adding

        scriptAlias/php-4.2.1-win32/ to

        ScriptAlias /cgi-bin/ "c:/wamp/Apache/cgi-bin/" and adding

        Action application/x-httpd-php/php/php.exe

        Format: Action media/type /cgi-script/location
        Format: Action handler-name /cgi-script/location

        dont know if i have to config the ADDType

        ServerAdmin: Your address, where problems with the server should be

        e-mailed. This address appears on some server-generated pages, such

        as error documents.

        #
        ServerAdmin duppdapp@msn.com

        #

        ServerName allows you to set a host name which is sent back to clients for

        your server if it's different than the one the program would get (i.e., use

        "www" instead of the host's real name).

        #

        Note: You cannot just invent host names and hope they work. The name you

        define here must be a valid DNS name for your host. If you don't understand

        this, ask your network administrator.

        If your host doesn't have a registered DNS name, enter its IP address here.

        You will have to access it by its address (e.g., http://123.45.67.89/)

        anyway, and this will make redirections work in a sensible way.

        #

        127.0.0.1 is the TCP/IP local loop-back address, often named localhost. Your

        machine always knows itself by this address. If you use Apache strictly for

        local testing and development, you may use 127.0.0.1 as the server name.

        #
        ServerName 127.0.0.1

          Make sure this line is in there:

          AddType application/x-httpd-php .php

            Write a Reply...