Vivid Lust Posted December 26, 2007 Share Posted December 26, 2007 I have the code: <?php $sumfile = "sum.txt"; $file = fopen( $sumfile, "r"); $filesize = filesize($sumfile); $sum = fread($file, $filesize); fclose( $file ); echo $sum; ?> <form name="1" method="post" action=" <?php $sumfile = "sum.txt"; $file = fopen( $sumfile, "a"); fwrite( $file, "1"); fclose( $file ); ?>"> <input type="submit" name="one" value="1"> </form> <form name="2" method="post" action=" <?php $sumfile = "sum.txt"; $file = fopen( $sumfile, "a"); fwrite( $file, "2"); fclose( $file ); ?>"> <input type="submit" name="two" value="2"> </form> And everytime i click on one input submit button both forms submit; this happens when refreshing aswell. (Im making a calculator) Please help! thanks in advanced and merry xmas. Quote Link to comment https://forums.phpfreaks.com/topic/83235-stop-all-forms-on-a-page-submitting-at-same-time/ Share on other sites More sharing options...
Vivid Lust Posted December 26, 2007 Author Share Posted December 26, 2007 Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/83235-stop-all-forms-on-a-page-submitting-at-same-time/#findComment-423486 Share on other sites More sharing options...
PHP_PhREEEk Posted December 26, 2007 Share Posted December 26, 2007 Doesn't matter how many submit buttons you create, all the form data will be sent. You have to check for the value of the submit button, then extract the $_POST data you expect for that 'sub-form' and ignore the others. PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/83235-stop-all-forms-on-a-page-submitting-at-same-time/#findComment-423493 Share on other sites More sharing options...
BenInBlack Posted December 26, 2007 Share Posted December 26, 2007 frankly this is not a submit issue, you can't put php code in the action of a form. as it is right now, it is just executing as php generates the form page. there is nothing in the action of the form if you look at source in your browser. so any submit, is just going to calc all the code you have in <?php .... ?> blocks Quote Link to comment https://forums.phpfreaks.com/topic/83235-stop-all-forms-on-a-page-submitting-at-same-time/#findComment-423495 Share on other sites More sharing options...
Vivid Lust Posted December 26, 2007 Author Share Posted December 26, 2007 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/83235-stop-all-forms-on-a-page-submitting-at-same-time/#findComment-423497 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.