我尝试研究可能的解决方案来完成我的任务。但我发现的似乎与我想要实现的不同。 我想在表单提交期间将记录插入表中。 insert sql位于php函数中,将在提交表单过程中调用。
以下代码可以使用,但不会将数据插入表格中。
请帮我找到以下代码中的问题: 非常感谢你。
<?php
$amt = 1000;
#calculate the total amount in cents.
$tamt = $amt * 100;
$desc = 'Paying 1,000 dollars';
$xx = substr(strtoupper("simba-gtpay") . strrev(md5($amt). substr(md5(date('i')), 20)), 15);
$userdata = $id;
$notify_url = 'http://www.eyohonesty.com/simba/members/gtpay_status.php';
$hashKey = "ok5";
$hash = hash('sha512',($xx . $amt . $notify_url . $hashKey));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Welcome | Simba Travels & Tours Ltd | Car Hire Services </title>
<style type="text/css">
<!--
.style1 {color: #CC3300}
-->
</style>
<!-- Start css3menu.com HEAD section -->
<link rel="stylesheet" href="../simbaMenuPub_files/css3menu1/style.css" type="text/css" /><style type="text/css">._css3m{display:none}</style>
<!-- End css3menu.com HEAD section -->
</head>
<body class="blurBg-false" style="background-color:#EBEBEB">
//在这里创建一个php函数
<?php
function tranx() {
$sql = mysql_query("insert into tran (cust_Id,tranx_amt,tranx_desc,tranx_date,tranx_status_msg)
values ('".$xx."', '".$id."', '".$amt."', '".$desc."', now(), 'Transaction Started')") or die(mysql_error());
return $sql;
}
?>
<form action="https://eyohonesty.com/simba/Tranx.aspx" method="post" name="transfer" id="transfer2" class="formoid-solid-orange" style="background-color:#FFFFFF;font-size:14px;font-family:'Roboto',Arial,Helvetica,sans-serif;color:#34495E;max-width:480px;min-width:150px">
<div><span style="font-weight:bold; font-size:14px; color:#FF9900;">You are paying:</span> <?php echo number_format($amt,0,".",",");?> </div>
<div><span style="font-weight:bold; font-size:14px; color:#FF9900;">Description:</span> <?php echo $desc;?> </div>
<div><span style="font-weight:bold; font-size:14px; color:#FF9900;">Transaction ID:</span> <?php echo $xx;?> </div>
<div><span style="font-weight:bold; font-size:14px; color:#FF9900;">Customer ID:</span> <?php echo $userdata;?> </div>
<input onclick="tranx()" type="submit" name="continue2" value="PROCEED TO PAYMENT"/></div>
//收集要通过帖子发送的隐藏字段
<?php
echo "
<input type=hidden name=_tranx_memo value=".$desc.">
<input type=hidden name=_cust_id value=".$userdata.">
<input type=hidden name=_tranx_amt value=".$tamt.">
<input type=hidden name=_tranx_noti_url value=".$notify_url.">
<input type=hidden name=_cust_name value=".$user.">
<input type=hidden name=_tranx_hash value=".$hash.">
<input type=hidden name=_echo_data value=".$desc . " Amount: =N= " . $amt . " Date: " .$today.">
"
?>
</form>