私はPayson支払いゲートウェイを使用しており、支払いが完了した後、ユーザーがありがとうページにリダイレクトされたときに、同じ2つの電子メールがユーザーに送信されます。この問題を解決するのを手伝ってください。コードは以下のとおりです。
$select="select * from #__content where id=12 and state=1";
$db->setQuery($select);
$result = $db->loadObject();
echo $result->introtext;
//echo $_REQUEST['id'];
$select = "select * from #__booking order by id desc";
$db->setQuery($select);
$db->query();
$id=$db->loadObject();
$insert_id=$id->id;
$printid=base64_encode($insert_id);
$db=& JFactory::getDBO();
$select_brand="select * from #__booking where id=".$id->id."";
$db->setQuery($select_brand);
$result = $db->loadObject();
$db=& JFactory::getDBO();
$select_brand="select * from #__brand where published=1 and id=".$result->brand."";
$db->setQuery($select_brand);
$result_brand = $db->loadObject();
$select_model="select * from #__modno where published=1 and id=".$result->model."";
$db->setQuery($select_model);
$result_model = $db->loadObject();
$printlink=JURI::root()."print.php?id=".$insert_id;
$link="http://www.status.repair24.se/?id=".$insert_id;
$phoneimagelink=JURI::root()."templates/mobile/images/phicon.png";
$logolink=JURI::root()."templates/mobile/images/2.png";
$to= $result->email;
$subject = "Invoice Mail";
$body.='<center><div style="width:100%;background-color:#f1f3f6;"><br>
<table bgcolor="#dde1e8" cellpadding="10" width="70%" style="border:1px solid #000;">
<tr><td>
<table bgcolor="white" align="center" cellpadding="5" cellspacing="5" width="100%" style="border:1px solid #000;">
<tr>
<td>
<table width="100%">
<tr>
<td align="left"><img src="'.$logolink.'" width="200"></td>
<td align="right"><img src="'.$phoneimagelink.'" style="margin:3px 5px -3px 0" alt="" border="0">123456789</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Name : '.$result->name.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Address: '.$result->address.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Zip Code: '.$result->zip.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Mobile : '.$result->mobile.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Email : '.$result->email.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Brand : '.$result_brand->name.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Model: '.$result_model->name.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Size '.$result->size.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Imei : '.$result->imei.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Operator : '.$result->operator.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Lock CODE : '.$result->lockcode.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Error Descriptions : '.rtrim($result->repairs,',').'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Price : '.$result->price.' SEK
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Repair Number : '.$result->num.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
<a href='.$printlink.'>Click here </a>to print Your Booking Details.
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
<a href='.$link.'>Click here </a>to check status.
</td>
</tr>
</table></td></tr></table><br><br></div></center>';
// To send HTML mail, the Content-type header must be set
$from = array("info@repair24.se", "Repair 24");
// To send HTML mail, the Content-type header must be set
# Invoke JMail Class
$mailer = JFactory::getMailer();
# Set sender array so that my name will show up neatly in your inbox
$mailer->setSender($from);
# Add a recipient -- this can be a single address (string) or an array of addresses
$mailer->addRecipient($to);
$mailer->setSubject($subject);
$mailer->setBody($body);
# If you would like to send as HTML, include this line; otherwise, leave it out
$mailer->isHTML(1);
# Send once you have set all of your options
$ma=$mailer->send();