Really noobish question.

Okay, I’m kinda bad at PHP, so don’t laugh at me…too hard…

Anyway, I’m trying to make this thing that calculates circumference from a form in which you can enter the diameter of a circle and have the site output the result. I have no idea what I should do from here…

[code]



<?php $circumference = $_REQUEST['diameter'] * 3.14 echo 'Circumference is '$circumference ?>[/code]

So…what am I doing wrong?

EDIT: Might help if I close the form! Tee hee. New code:

[code]



<?php $circumference = $_REQUEST['diameter'] * 3.14 echo 'Circumference is '$circumference ?>[/code]

So did closing the form tag fix the problem?

No…really, I don’t think it’s a problem. It’s just I’m not positive on how to do this…

The php code would be:

<?ohp if ($_POST['diameter']) { $circumference = $_POST['diameter'] * 3.14; echo "Circumference is $circumference"; } ?>

So…where do I put that code? In between the form tags? After the form?

Please excuse my noobishness… :oops:

Oh, and you spelled “php” wrong…

doesn’t matter where. Where ever you want the echo text to show up.

Hm, yes. So how would I make it so that when you press the button it echoes?

I am such a noob.

Try doing this:

[code]



<?php if(isset($_POST['sent']) and $_POST['sent'] == "123456){ $circumference = $_POST['diameter'] * 3.14; echo 'Circumference is ' . $circumference; } else {} ?>[/code] not sure it will work though

That won’t work. Just is the code I gave you. It will already check to see if the form was posted.

The if ($_POST[‘diameter’]) does that already.

Sponsor our Newsletter | Privacy Policy | Terms of Service