Jump to content

booking notification email to consultants.


matt.sisto

Recommended Posts

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.

Link to comment
Share on other sites

<?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  ???

Link to comment
Share on other sites

$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");

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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();
}

Link to comment
Share on other sites

  $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.

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.