mikebyrne Posted August 14, 2009 Share Posted August 14, 2009 I have a form with two input boxes "n" and "m" which I want to place into the following formula 1-n/(n+m) How do I code the php to do this? my form looks like this: <form> First name: <input type="text" name="N" /> <br /> Last name: <input type="text" name="M" /> </form> Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted August 14, 2009 Share Posted August 14, 2009 $n = $_POST['n']; $m = $_POST['m']; $answer = 1-$n/(n+m); ? Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted August 14, 2009 Author Share Posted August 14, 2009 Thanks for your quick reply How could I code a submit button so that when the user presses the button it runs the formula?? Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted August 14, 2009 Share Posted August 14, 2009 well there are multiple ways. you need to read a tutorial on how php and html forms communication: http://www.tizag.com/phpT/examples/formex.php/ you can also use javascript and the HTML DOM to do it more dynamically http://www.w3schools.com/js/js_obj_htmldom.asp Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted August 14, 2009 Author Share Posted August 14, 2009 My code so far is <form> N: <input type="text" name="N" /> <br /> M: <input type="text" name="M" /> <INPUT type="submit" name="mysubmit" value="Click!"> </form> <?php $n = $_POST['n']; $m = $_POST['m']; $answer = 1-$n/(n+m); ?> I know im not a million miles away Quote Link to comment 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.