I have an event booking Wordpress website in which people, after booking receive an email regarding their booking details. That details get stored in an MYSQL Row. But if that person has more than one booking or has multiple records of different seats. Then whenever he tries to get a confirmation email for his second booking, only the first record is being fetched from the database, not the second one. Is there a way to get two emails at the same time for two bookings.
Here is my code:
<?php
date_default_timezone_set('Asia/Dhaka');
/*---------------DB connectivity start--------------------------------*/
$host="host";
$user="user";
$password="password";
$db="db";
mysql_connect($host,$user,$password);
mysql_select_db($db);
if(isset($_POST['email'])){
$email1=$_POST['email'];
//echo "Email id ";
// echo $email1;
$query="select * from wp_bap_orders where email='".$email1."' ";
$result=mysql_query($query);
$count=mysql_num_rows($result);
if($result->num_rows > 0)
{
while ($rows=mysqli_fetch_row($result)){
$rows=mysql_fetch_array($result);
$orderid = $rows['order_id'];
$name1 = $rows['first_name'];
$name2 = $rows['last_name'];
$name3 = $name1 . " " . $name2;
$email2 = $rows['email'];
$phone = $rows['phone'];
$date = $rows['date'];
$code = $rows['code'];
$places = $rows['places'];
//collect seat numbers
$seatnumbersstr = '';
foreach(unserialize($rows['places']) as $placearr){
$seatnumbersstr=$seatnumbersstr.','.$placearr['place_name'];
}
$price = $rows['total_price'];
$scheme_id = $rows['scheme_id'];
$event_id = $rows['event_id'];
$event = $rows['event'];
$payment_type = $rows['payment_type'];
//echo $scheme_id ;
$qry1="select * from wp_bap_schemes where scheme_id='$scheme_id '";
$result1=mysql_query($qry1);
$count1=mysql_num_rows($result1);
if($count1==1)
{
$rows1=mysql_fetch_array($result1);
$eventname = $rows1['name'];//FETCHING EVENT NAME
$eventdesc = $rows1['description'];//FETCHING EVENT NAME
}
//echo $eventname;
//echo " was found";
$message = "
<html>
<body>
<center>
<p align='center'>
<font face='Verdana'><u><b><font size='4' color='#800000'>
Booking confirmation mail</font></b></u></font>
</p>
<table border='0' cellspacing='1' width='92%' id='AutoNumber10' class='simpletext'>
<tr>
<td align='right'> <strong> Name :</strong></td>
<td > </td>
<td >". $name3."</td>
</tr>
<tr>
<td align='right'> <strong>Email :</strong></td>
<td > </td>
<td >". $email2 ."</td>
</tr>
<tr>
<td align='right'> <strong>Phone No :</strong></td>
<td > </td>
<td >". $phone ."</td>
</tr>
<tr>
<td align='right'> <strong>Seat Number :</strong></td>
<td > </td>
<td >". $seatnumbersstr ."</td>
</tr>
<tr>
<td align='right'> <strong>Event Booked :</strong></td>
<td > </td>
<td >". $eventname ."</td>
<tr>
<td align='right'> <strong>Show :</strong></td>
<td > </td>
<td >". $eventdesc."</td>
</tr>
</tr>
<tr>
<td align='right'> <strong>Amount :</strong></td>
<td > </td>
<td >". $price."</td>
</tr>
<tr>
<td align='right'> <strong>Transitional ID :</strong></td>
<td > </td>
<td >". $code."</td>
</tr>
</table>
<h3 align='left'>Dear ". $name3 . ",</h3>
<p align='left'>Thank you for your booking with nokta.</p>
</body>
</html>";
}
//$to="$email1";
$to="admin@onesolution.co.in";
$subject = "Booking Confirmation email";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";
$headers .= "From: info@noktaarts.com" . "
" .
"CC: admin@onesolution.click";
mail($to,$subject,$message,$headers);
echo '<script> alert("We Have Send Your Booking Ticket To Your Email Address. Please Ckeck Your Email."); window.location="index.php"; </script>';
// print "<script>alert('We Have Send Your Booking Ticket To Your Email Address.</br>Please Ckeck Your Email.'); </script>";
//echo "You Have Received Your Booked Ticket Vai Email.</br> Please Check Your Email.";
}
else
{
echo"Not found";
}
}
?>