HI
I have a button on a form on a html page and the action of the button is to go to a php script which processes the variables of the form. This is working fine but the php page loads straight after I press the button. I don’t want this . I want the original page to stay visible.
Can anyone help?
Here is an example of the button on the form:
<form action="form.php" method="post">
<input type="hidden" name="var3" value="hidden value3"><br>
<button type="submit" formaction="form.php">Submit hidden values in var 3</button>
</form>
as you can see the form.php gets run and it opens a new blank page.
Here is the script in form.php:
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$var1 = $_POST["var1"];
$var2 = $_POST["var2"];
$var3 = $_POST["var3"];
$fp = fopen("formdata.txt", "a");
$savestring = $name . "," . $email . "," . $var1 . "," . $var2 . $var3 . "\n";
fwrite($fp, $savestring);
fclose($fp);
//echo "<h1>from form.php Your data should be saved in formdata! $name $email $var1 $var2 $var3</h1>";
?>