Jump to content

Wont send email


princeofpersia

Recommended Posts

guys, in the code below (this is just a demonstration) i need to find out once a card payment has been done, the code changes the status of the order but it doesnt send email. can u please help me find out why?

 

<?php

session_start();
include ("includes/db.php");
include ("includes/function.php");
//authentication
if (loggedin()==FALSE)
{
Header("Location: login.php");
exit();
}
//username session
$_SESSION['username']=='$username';
$username=$_SESSION['username'];
echo "Welcome, " .$_SESSION['username']."!<p>";


//get user id


$getdetails=mysql_query("SELECT * FROM users WHERE username='$username'");
while($row = mysql_fetch_array($getdetails))
{
$users_id=$row['id'];
$email=$row['email'];


}

$getdetails=mysql_query("SELECT * FROM booking WHERE users_id='$users_id' AND status='pending'");

$totaloforders=mysql_num_rows($getdetails);

while($row = mysql_fetch_array($getdetails))
{
$users_id=$row['id'];
$bookedtime=$row['time'];
$bookeddate=$row['date'];
$bookedseat=$row['seat_no'];


echo "

      <td>Swinging For Seat: $bookedseat on $bookeddate at $bookedtime</td><br/>
	  
        
";
echo "</table>";	
}


//get the firstname
$myfirstname=$_SESSION ['firstname'];

//get the lastname
$mylastname=$_SESSION ['lastname'];

//get the email
$myemail=$_SESSION ['email'];


//get the seat number
$myseatnumber=$_SESSION ['seatnumber'];

//get the booking time
$mytime=$_SESSION ['time'];

//get the booking date
$mybookingdate=$_SESSION ['datetime'];


//get the ride id
$ride=$_SESSION ['ride'];

//get the bookings

$select=mysql_query("SELECT * FROM booking WHERE users_id='$users_id'");
while ($row=mysql_fetch_array($select)){

$id=$row['id'];
$date=$row['$date'];
$time=$row['time'];



}


///////////////////////////////////////////////////////////////////////////////////////////////
// Calculate the price plus VAT, VAT at current time is 20% of each service
$price=mysql_query("SELECT price FROM ride_type WHERE id='$ride'");
while ($row=mysql_fetch_array($price)){
$rideprice=$row['price'];	}
$net=$totaloforders*$rideprice;

$vat=$net*20/100;

$finalprice=$net+$vat;
//////////////////////////////////////////////////////////////////////////////////////////////
    if ($_POST['pay'])
{
/**
Validation
*/

		$cardNo = addslashes(strip_tags($_POST['cardNo']));
	$cc = addslashes(strip_tags($_POST['cc']));
	$expire = addslashes(strip_tags($_POST['expire']));

	if ($cardNo == "" ||$cc == "" || $expire == "" ) {

		echo "Please insert full credit card details";
	}

	else

	{


function luhnCheck($cardNo) {
    $cardNo = str_replace(" ", "", trim($cardNo));
    if(!is_numeric($cardNo) or strlen($cardNo)>19) return false;
    $skip = $newNum = $total = 0;
    for($i=0;$i<=(strlen($cardNo)-1);$i++) {
        if($skip ==0) {
            $tmpNum = ($cardNo[$i]*2);
            $total += (strlen($tmpNum)==2 ? (substr($tmpNum, 0, 1)+substr($tmpNum, 1)) : $tmpNum);
            $skip = 1;
        }else{
            $total += $cardNo[$i];
            $skip = 0;
        }
    }
    return (($total % 10) == 0);
}

/* Example Usage */
if(luhnCheck) {

$updatebooking=mysql_query("UPDATE booking SET status='completed' WHERE users_id='$users_id' AND date='$bookeddate' AND time='$bookedtime' AND status='pending'"); 

$select=mysql_query("SELECT * FROM booking WHERE ride_id='1' AND users_id='$users_id' AND seat_no='$bookedseat' AND status='completed'");

while($row=mysql_fetch_array($select))
{ 
$donetime=$row['time'];
$donedate=$row['date'];
$doneseat=$row['seat_no'];


  }
            $to = $email;
           $subject = "Your Ticket";
           $headers = "From: mina@minashirazi.com";
           $body = "Hello $username,\n\n
	   
 <table>


Please find the tickets you have booked.
      <td>Swinging For Seat: $doneseat on $donedate at $donetime</td>

        

</table>";	
	   


  
  
}
  else
  
{

 echo"There was an error updating your details";
 }
   // echo("Valid Number.");


//}else{
//    echo("Invalid Number.");
}

}

?>



<html>
<head>
</head>
<body>


<form name="confirm" method="post" action="">
      <p>      First Name:<br />
        <input type="text" name='firstname' value="<? echo "$myfirstname";?>">
        
              <p>      Last Name:<br />
        <input type="text" name='lastname' value="<? echo "$mylastname";?>">
        
                      <p>      Email:<br />
        <input type="text" name='email' value="<? echo "$myemail";?>">
    
  <p>      Net Price :<br />
    <? echo "$rideprice"; ?>
    
                    pounds<p>      VAT :<br />
    <? echo "$vat"; ?>

                    pounds<p>      Total :<br />
    <? echo "$finalprice"; ?>



              pounds<p>
              
              Card No:<br/>
              <input type="text" name="cardNo">
              <p>CCV:<br/>
              <input type="text" name="cc">
              <p>Expiry Date<br/>
             <input type="text" name="expire" value="e.g 12/10">
              <p>
                <input type="submit" name="pay" value="Pay Now">
                
</form>
</body>


 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.