1

At the moment I am working on a form that on submit goes to a payment gateway to allow the user to pay for the event they registered for. The payments and form are working correctly.

I store the generated merchant session ID and other values in to my database (mySQL) when the user goes to make a payment.

The problem I am having is how do I check that once payment is made and the payment site returns the values that the merchant session ID is the same and update the payment status column in that existing row.

I'm really not sure how I do this with php and I think that is where the problem lies. I have been googling but to no avail..

What I've tried has been along the lines of:

$merchant = $_GET['ms'];
$status = $_GET['ec'];
if ($merchant == 'session')
{
$sql ="UPDATE $tbl_name SET paystatus='$status' WHERE session = '$merchant'";
}

I'm not sure if I need to specify to update the column of that exact row where merchant == session or how.

4

1 回答 1

0
$merchant = $_GET['ms'];//merchant
$status = $_GET['ec'];//error code
$query = "SELECT `merchant` FROM `tbl` WHERE `merchant` = '".$merchant."'";//select merchant column where merchant variable is in your table
$result = mysqli_query($query); //query
if ($result&&$status!=0)//if query succeeds and error != 0
{
$sql ="UPDATE $tbl_name SET paystatus='".$status."' WHERE session = '".$merchant."'";//update
$doquery = mysqli_query($sql);//query
}

这应该做你想要的。

于 2013-06-09T06:50:33.507 回答