Jump to content

Recommended Posts

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.

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.