i have a Button, that executes php Code after click(I am testing something with EMails and everything is working so far, except this Issue with the "PHP Script loading after Refresh" Problem):
HTML:
<form method="post">
<input type="submit" name="button1"
class="button" value="Button1" />
<input type="submit" name="button2"
class="button" value="Button2" />
</form>
PHP:
<?php
if(array_key_exists('button1', $_POST)) {
button1();
}
else if(array_key_exists('button2', $_POST)) {
button2();
}
function button1() {
echo "mail";
}
function button2() {
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "test@example.de";
$to = "thisIsA@secret.de";
$subject = "Betreff";
$message = "Text";
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
echo "Test email sent";
}
?>
When i first go to the Site, everything is working and the script is not executing, before I press one of the Buttons. Thats perfect -> BUT when I refresh the Page, the script gets executed without me pressing the Button.
How can I prevent the script loading after refresh?