Reputation: 128
I have a script that processes payments from a payment provider, and then uses a PHP
redirect to show a "thank you" page.
Source: (Websend.php include source is here: http://pastebin.com/raw.php?i=TmmysJiD)
include_once 'Websend.php';
if ($file != "GREAT") {
header("Location: ../failed.html");
exit();
} else {
$ws = new Websend("192.168.56.105");
$ws->connect("passwd");
$ws->doCommandAsConsole("give " . $token . " 2000");
$ws->disconnect();
header('Location: ../success.html');
exit();
}
Source of success.html
<head>
<meta http-equiv="refresh" content="0; url=http://site.com/index.html">
</head>
<script type="text/javascript">
alert("Some alert");
</script>
However header("Location: ../success.html");
is causing the command to run twice (and give the user the amount twice, which should not happen.
When I remove header("Location: ../success.html");
the code works as it should be.
Why does this happen?
Upvotes: 1
Views: 1658
Reputation: 24723
This is refreshing success.html
<meta http-equiv="refresh" content="0; url=http://site.com/index.html">
EDITED
have you tried removing <meta http-equiv="refresh" content="0; url=http://site.com/index.html">
? Also try changing header('Location: ../success.html');
to header('Location: ../index.html');
Upvotes: 1