Hye开发人员,我正在设计一个验证用户卡详细信息的支付网关,我想将用户重定向到一个页面,如果它正确且付款成功,我正在使用
<?php
require_once 'wallet.class.php';
$class = new wallet('mysql:host=127.0.0.1;dbname=pooldb', "root", ""); // change the host and database to the host server
// making payment
if(isset($_REQUEST["amount"])){
$card = [
"card_no" => $_REQUEST["cardNO"],
"cvv" => $_REQUEST["cvc"],
"expiry_month" => $_REQUEST["month"],
"expiry_year" => $_REQUEST["year"]
];
$info = [
"id" => 1, // Login in user
"amount" => $_REQUEST["amount"], // amount
"url" => "http://payment.php" // response URL
];
$token = $class->Tokenize($_REQUEST["auth"], $card, $_REQUEST["bvn"]);
if($token == "Token True"){
$payment = $class->Payment($card, $info);
if($payment == "Paid True"){
$class->CheckUser_AndSave($info["id"], $info["amount"]);
header("Location:upload.php");
exit();
}
else if($payment == "Paid False"){
// make an action to dispaly and input box and button for OTP
echo "Paid False";
$_SESSION['mssage'] = $class->message;
}
else{
echo $payment; // error message
}
}
else{
echo "Your card was not tokenize. Try agin.";
}
}
// doing OTP action here
elseif (isset ($_REQUEST["otp"])) { // Send entered OTP here
$info = [
"id" => 1, // Login in user
"amount" => $_REQUEST["amount"], // amount
];
$otp = $class->OTP($_REQUEST["otp"]);
if($otp == "OTP True"){
$class->CheckUser_AndSave($info["id"], $info["amount"]);
}
else{
echo "Something went wrong.";
}
}
但不是重定向到上传页面,而是只显示在当前页面下方,一切都是拉伸的,请我帮忙
答案 0 :(得分:0)
您应该重定向并退出,如下所示
if($payment == "Paid True"){
$class->CheckUser_AndSave($info["id"], $info["amount"]);
header("Location:upload.php");
exit();
}
另外请确保在此行之前没有回复/打印任何内容。
答案 1 :(得分:0)
使用javascript重定向,如Japanguy建议,它现在有效
if($payment == "Paid True"){
$class->CheckUser_AndSave($info["id"], $info["amount"]);
echo "<script>
window.location.href='upload.php';
</script>";
}