我有这部分代码,我使用它来防止查询提交两次!现在,这是我用来使它工作的查询,它工作。
$form_secret = isset($_POST["form_secret"])?$_POST["form_secret"]:'';
$query = "INSERT INTO coupon (user_id,points) VALUES ('$user_id','$points')";
$result=mysql_query($query);
if ($points == 250)
{
$url="http://testext.i-movo.com/api/receivesms.aspx?".$str_from.$str_zip.$phone.$str_time.$date1.$str_msg;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
else if ($points == 500)
{
$url="http://testext.i-movo.com/api/receivesms.aspx?".$str_from.$str_zip.$phone.$str_time.$date1.$str_msg;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
else
{
echo "We are sorry, you don't possess enough points in order to take the coupon";
}
完美到现在!然后我需要的是防止重复提交,因此我在这里使用此代码,但问题是,当我将上述所有代码放入此代码时,它不起作用..任何人请告诉我如何统一这个两个代码?谢谢..
if(isset($_SESSION["FORM_SECRET"]))
{
if(strcasecmp($form_secret, $_SESSION["FORM_SECRET"]) === 0)
{
/*Put your form submission code here after processing the form data, unset the secret key from the session*/
unset($_SESSION["FORM_SECRET"]);
}
else
{
//Invalid secret key
}
}
else
{
//Secret key missing
echo "Form data has already been processed!";
}