matt.sisto Posted May 20, 2009 Share Posted May 20, 2009 Hello, I am trying to get my script to notify the consultant sif a booking is successful, burt it just defaults to the index page when it reaches my mail script: <?php $sql = "INSERT INTO calendar_events VALUES (0,'".$event_start."','".$end_date."','".$client_id."','".$service."','".$unit."','".$quantity."','".$start_time."','".$end_Time."','".$con_id1."','".$con_id2."','".$con_id3."','".$eventTotal."','".$address_first_line."','".$post_code."','".$country."','".$extra_info."')"; $result = mysql_query ($sql, $connection) or die ("Couldn't perform query $sql <br />".mysql_error()); $sql = "SELECT first_name FROM client WHERE client_id= '$client_id'"; $firstName = mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); $sql = "SELECT last_name FROM client WHERE client_id= '$client_id'"; $lastName = mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); $clientName = $firstName." ".$lastName; if ($con_id1 != null){ $sql = "SELECT email_address FROM consultant WHERE con_id= '$con_id1'"; $to = mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); } if ($con_id2 != null){ $sql = "SELECT email_address FROM consultant WHERE con_id= '$con_id2'"; $to.= mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); } if ($con_id3 != null){ $sql = "SELECT email_address FROM consultant WHERE con_id= '$con_id3'"; $to.= mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); } $sender = 'admin@salmonsreach.org'; $headers = "SRC: Administrative Team"; $message = "We would like to notify you that a client has booked an appointment with you. Thanks and Regards, SRC Administrative Team. <br /> Event date: $event_start <br /> Event end date: $ $end_date <br /> Service: $service <br /> Start time: $start_time <br /> Address: $address_first_line <br /> Post Code: $post_code <br /> Client: $clientName"; if(mail($to, $sender, $message, $headers)){ header("Location: confirmation.php"); exit(); } ?> Any help appreciated. Thanks and regs. Quote Link to comment Share on other sites More sharing options...
matt.sisto Posted May 21, 2009 Author Share Posted May 21, 2009 <?php $sql = "INSERT INTO calendar_events VALUES (0,'".$event_start."','".$end_date."','".$client_id."','".$service."','".$unit."','".$quantity."','".$start_time."','".$end_Time."','".$con_id1."','".$con_id2."','".$con_id3."','".$eventTotal."','".$address_first_line."','".$post_code."','".$country."','".$extra_info."')"; $result = mysql_query ($sql, $connection) or die ("Couldn't perform query $sql <br />".mysql_error()); $sql = "SELECT first_name FROM client WHERE client_id= '$client_id'"; $firstName = mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); $sql = "SELECT last_name FROM client WHERE client_id= '$client_id'"; $lastName = mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); $clientName = $firstName." ".$lastName; if ($con_id1 != null){ $sql = "SELECT email_address FROM consultant WHERE con_id= '$con_id1'"; $to = mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); } if ($con_id2 != null){ $sql = "SELECT email_address FROM consultant WHERE con_id= '$con_id2'"; $to.= mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); } if ($con_id3 != null){ $sql = "SELECT email_address FROM consultant WHERE con_id= '$con_id3'"; $to.= mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); } $sender = 'admin@salmonsreach.org'; $headers = "SRC: Administrative Team"; $message = "We would like to notify you that a client has booked an appointment with you. Thanks and Regards, SRC Administrative Team. <br /> Event date: $event_start <br /> Event end date: $end_date <br /> Service: $service <br /> Start time: $start_time <br /> Address: $address_first_line <br /> Post Code: $post_code <br /> Client: $clientName"; if(mail($to, $sender, $message, $headers)){ header("Location: confirmation.php"); exit(); } ?> I noticed a mistake and I have now changed it, but still not working. Any ideas ??? Quote Link to comment Share on other sites More sharing options...
sellfisch Posted May 21, 2009 Share Posted May 21, 2009 $lastName = mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); mysql_query only provide the result of an query. If you want to get the lastname for example you have to do it like this: $result = mysql_query ($sql); $lastname=mysql_result($result,0,"lastName"); Quote Link to comment Share on other sites More sharing options...
matt.sisto Posted May 21, 2009 Author Share Posted May 21, 2009 OK so I have now modified it taking your advice on board but still having major issues, if anyone can help, it would be greatly appreciated, I'm not sure if the mail script it self is right, if I have used the variables correctly ??? $sql = "SELECT first_name FROM client WHERE client_id= '$client_id'"; $result = mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); if($result !=null){ $firstName =mysql_result($result,0,"first_name"); } $sql = "SELECT last_name FROM client WHERE client_id= '$client_id'"; $result = mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); if($result !=null){ $lastName =mysql_result($result,0,"last_name"); } if ($con_id1 != null){ $result = mysql_query("SELECT email_address FROM consultant WHERE con_id= '$con_id1'"); if($result !=null){ $to =mysql_result($result,0,"email_address"); } } if ($con_id2 != null){ $result = mysql_query("SELECT email_address FROM consultant WHERE con_id= '$con_id2'"); if($result !=null){ $to.=mysql_result($result,0,"email_address"); } } if ($con_id3 != null){ $result = mysql_query("SELECT email_address FROM consultant WHERE con_id= '$con_id3'"); if($result !=null){ $to.=mysql_result($result,0,"email_address"); } } $result = mysql_query ($sql); $lastname=mysql_result($result,0,"lastName"); $sender = 'admin@salmonsreach.org'; $headers = "SRC: Administrative Team"; $message = "We would like to notify you that a client has booked an appointment with you. Thanks and Regards, SRC Administrative Team. <br /> Event date: $event_start <br /> Event end date: $end_date <br /> Service: $service <br /> Start time: $start_time <br /> Address: $address_first_line <br /> Post Code: $post_code <br /> Client: $firstName $lastName"; if(mail($to, $sender, $message, $headers)){ header("Location: confirmation.php"); exit(); } Thanks and regs. Quote Link to comment Share on other sites More sharing options...
matt.sisto Posted May 21, 2009 Author Share Posted May 21, 2009 What am I doing wrong? $sender = 'admin@salmonsreach.org'; $headers = "SRC: Administrative Team"; $message = "We would like to notify you that a client has booked an appointment with you. Thanks and Regards, SRC Administrative Team. <br /> Event date: $event_start <br /> Event end date: $end_date <br /> Service: $service <br /> Start time: $start_time <br /> Address: $address_first_line <br /> Post Code: $post_code <br /> Client: $firstName $lastName"; if(mail($to, $sender, $message, $headers)){ header("Location: confirmation.php"); exit(); } Quote Link to comment Share on other sites More sharing options...
matt.sisto Posted May 21, 2009 Author Share Posted May 21, 2009 $sql = "SELECT first_name FROM client WHERE client_id= '$client_id'"; $result = mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); if($result !=null){ $firstName =mysql_result($result,0,"first_name"); } $sql = "SELECT last_name FROM client WHERE client_id= '$client_id'"; $result = mysql_query ($sql, $connection) or die ("Could not perform query $sql <br />".mysql_error()); if($result !=null){ $lastName =mysql_result($result,0,"last_name"); } if ($con_id1 != null){ $result = mysql_query("SELECT email_address FROM consultant WHERE con_id= '$con_id1'"); if($result !=null){ $to =mysql_result($result,0,"email_address"); } } if ($con_id2 != null){ $result = mysql_query("SELECT email_address FROM consultant WHERE con_id= '$con_id2'"); if($result !=null){ $to.=mysql_result($result,0,"email_address"); } } if ($con_id3 != null){ $result = mysql_query("SELECT email_address FROM consultant WHERE con_id= '$con_id3'"); if($result !=null){ $to.=mysql_result($result,0,"email_address"); } } $result = mysql_query ($sql); $lastname=mysql_result($result,0,"lastName"); $sender = 'admin@salmonsreach.org'; $headers = "SRC: Administrative Team"; $message = "We would like to notify you that a client has booked an appointment with you. Thanks and Regards, SRC Administrative Team."; $message.= "<br /> Event date: ".$event_start."\n"; $message.= "<br /> Event end date: ".$end_date."\n"; $message.= "<br /> Service: ".$service."\n"; $message.= "<br /> Start time: ".$start_time."\n"; $message.= "<br /> Address: ".$address_first_line."\n"; $message.= "<br /> Post Code: ".$post_code."\n"; $message.= "<br /> Client: ".$firstName." ".$lastName."\n"; if(mail($to, $sender, $message, $headers)){ header("Location: confirmation.php"); exit(); } I have tried this but still no joy. Any ideas. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.