sp00ks Posted October 23, 2008 Share Posted October 23, 2008 I thought i figured out how to allow the user to insert a number, and then get php to call a function to figure out the radius of that number. I am getting the right number back, but also an error message. This tells me my structure of the code is incorrect. If you know a better way to implement this that would be excellent. thanks! Error: Notice: Use of undefined constant radius - assumed 'radius' in C:\wamp\www\****.php on line 13 code: <?php //define a function if(!isset($_POST['submit'])){ ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> Enter the radius of the circle<input type="text" name="radius" size="5"/> <input type="submit" name="submit" value="Go"/> </form> <?php }else { $rad = $_POST[radius]; getCircumference($rad); } function getCircumference ($radius){ echo"Circumference of a circle with radius $radius is ".sprintf("%4.2f", (2 * $radius * pi()))."<br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/129782-getting-results-but-an-error-message-as-well/ Share on other sites More sharing options...
GKWelding Posted October 23, 2008 Share Posted October 23, 2008 Change $rad = $_POST[radius]; to $rad = $_POST["radius"]; and let me know if that helps. Quote Link to comment https://forums.phpfreaks.com/topic/129782-getting-results-but-an-error-message-as-well/#findComment-672828 Share on other sites More sharing options...
sp00ks Posted October 23, 2008 Author Share Posted October 23, 2008 Thanks that worked wonderfully. I guess if the input is going to be text(or anything) i have to call it as such. thanks for the quick answer! EDIT: not sure how to mark my title as [solved]... Quote Link to comment https://forums.phpfreaks.com/topic/129782-getting-results-but-an-error-message-as-well/#findComment-672888 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.