Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to tell php script to skip line 508 if the customeremail field is left empty?

    I have a client that wants his dealers to be able to optionally send a "Thank You" email response generated and emailed to their customer.

    All fields in form are required except customeremail. If the client enters their customers email the form works fine. If the client omits the customer's email, the email responses are sent to the form's owner and the client, but the following message shows on the successful page: Warning: mail(): SMTP server response: 554 5.5.1 Error: no valid recipients in C:\Inetpub\Welsch\submitphototest.php on line 508.

    Line 508 reads:

    if(mail($customeremail, $Subject1, $msg1, $headers1));

    I know the error message is given because the client has left the customeremail blank, but how can I tell the script to skip line 508 if the customeremail is blank? The following is the entire php script

    <?




    }elseif($_POST['runprogram'] == "yes"){


    $To_Address = "ptyler@tsconard.com";
    //orders@welsch-enterprises.com
    $eol="\n";
    $Momentn = mktime().".".md5(rand(1000,9999));
    $boundary = md5(uniqid(rand()));
    $msg = "";
    $Customer_Name=stripslashes($Customer_Name);
    if(!isset($Image_name)){ $Image_name = $_FILES['Image']['name']; }
    if(!isset($Image_type)){ $Image_type = $_FILES['Image']['type']; }

    $headers .= 'To: '.$To_Address.$eol;
    $headers .= 'From: '.$Email_Address.$eol;
    $headers .= 'Date: '.date("r").$eol;
    $headers .= "X-Mailer: PHP/".phpversion()."\n";
    $headers .= 'MIME-Version: 1.0'.$eol;
    if(file_exists($Image)){ //if Image exists
    $headers .= "Content-Type: multipart/mixed;\n";
    $headers .= "\tboundary=\"$boundary\"\n";
    $msg .= "This is a multi-part message in MIME format.\n\n";
    $msg .= "--$boundary\n";
    $msg .= "Content-Type: text/plain; charset=ISO-8859-1\n";
    $msg .= "Content-Transfer-Encoding: 7bit\n\n";
    }else{
    $headers .= "Content-Type: text/plain; charset=ISO-8859-1\n";
    $headers .= "Content-Transfer-Encoding: 7bit\n";
    }

    $msg .= $Month1."/".$Day1."/".$Year1.",".$Customer_Name.",".$Address.",".$City.",".$State.",".$Zip_Code.",".$customeremail.",".$ Dealership_Realtor_Name.",".$Submitted_By.",".$Email_Address;
    $linking = "&Email_Address=".$Email_Address."&Submitted_By=".str_replace(" ","%20",$Submitted_By)."&Dealership_Realtor_Name=".str_replace(" ","%20",$Dealership_Realtor_Name);
    if(file_exists($Image)){
    $fp = fopen($Image, "r") or die("error");
    $contents = fread($fp, filesize($Image));
    fclose($fp);
    $f_encoded = chunk_split(base64_encode($contents));
    $msg .= "\n--$boundary\n";
    $msg .= "Content-Type: " . $Image_type . ";\n";
    $msg .= "\tname=\"$Image_name\"\n";
    $msg .= "Content-Transfer-Encoding: base64\n";
    $msg .= "Content-Disposition: attachment;\n";
    $msg .= "\tfilename=\"$Image_name\"\n\n";
    $msg .= "$f_encoded\n";
    }
    $msg .= "--$boundary--";

    // $Subject = "Submit Photo Online Form";
    $Subject = $Dealership_Realtor_Name;

    /* E-mail to Dealer / Realtor's Customer */

    $eol="\n";
    $Momentn = mktime().".".md5(rand(1000,9999));
    $boundary = md5(uniqid(rand()));

    $msg1 = "";
    if($customeremail_exists)

    if(!isset($Image_name)){ $Image_name = $_FILES['Image']['name']; }
    if(!isset($Image_type)){ $Image_type = $_FILES['Image']['type']; }



    $headers1 .= 'To: '.$customeremail.$eol;
    $headers1 .= 'From: '.$Email_Address.$eol;
    $headers1 .= 'Date: '.date("r").$eol;
    $headers1 .= "X-Mailer: PHP/".phpversion()."\n";
    $headers1 .= 'MIME-Version: 1.0'.$eol;

    if(file_exists($Image)){ //if Image exists
    $headers1 .= "Content-Type: multipart/mixed;\n";
    $headers1 .= "\tboundary=\"$boundary\"\n";
    $msg1 .= "This is a multi-part message in MIME format.\n\n";
    $msg1 .= "--$boundary\n";
    $msg1 .= "Content-Type: text/plain; charset=ISO-8859-1\n";
    $msg1 .= "Content-Transfer-Encoding: 7bit\n\n";
    }else{
    $headers1 .= "Content-Type: text/plain; charset=ISO-8859-1\n";
    $headers1 .= "Content-Transfer-Encoding: 7bit\n";
    }




    $msg1 .= "Dear " .$Customer_Name.",\n\nAgain we want to thank you for your valued business, attached is the photograph we took of you with your new purchase.\n\nSafe Riding,\n\n".$Dealership_Realtor_Name."\n";



    if(file_exists($Image)){
    $fp = fopen($Image, "r") or die("error");
    $contents = fread($fp, filesize($Image));
    fclose($fp);
    $f_encoded = chunk_split(base64_encode($contents));
    $msg1 .= "\n--$boundary\n";
    $msg1 .= "Content-Type: " . $Image_type . ";\n";
    $msg1 .= "\tname=\"$Image_name\"\n";
    $msg1 .= "Content-Transfer-Encoding: base64\n";
    $msg1 .= "Content-Disposition: attachment;\n";
    $msg1 .= "\tfilename=\"$Image_name\"\n\n";
    $msg1 .= "$f_encoded\n";
    }
    $msg1 .= "--$boundary--";

    $Subject1 = 'Thank You From '.$Dealership_Realtor_Name."\n";


    //customer e-mail
    $headers2 .= 'To: '.$Email_Address.$eol;
    $headers2 .= 'From: '.$To_Address.$eol;
    $headers2 .= 'Date: '.date("r").$eol;
    $headers2 .= "X-Mailer: PHP/".phpversion()."\n";
    $headers2 .= 'MIME-Version: 1.0'.$eol;
    $headers2 .= "Content-Type: text/plain; charset=ISO-8859-1\n";
    $headers2 .= "Content-Transfer-Encoding: 7bit\n";
    $Subject2 = "Welsch Enterprise Confirmation E-mail";
    $msg2 .= "The following information has been successfully submitted and recieved by orders@welsch-enterprises.com.\n";
    $msg2 .= "Customer Name : ".$Customer_Name."\n";

    $msg2 .= "Address : ".$Address."\n";
    $msg2 .= "City, State, ZIP : ".$City.",".$State." ".$Zip_Code."\n";
    $msg2 .= "Customer E-mail : ".$customeremail."\n";
    $msg2 .= "Date of Purchase : ".$Month1."/".$Day1."/".$Year1."(MM/DD/YYYY)\n";
    $msg2 .= "Attached file name : ".$Image_name."\n";
    $msg2 .= "Dealership Realtor Name : ".$Dealership_Realtor_Name."\n";
    $msg2 .= "Submitted By : ".$Submitted_By."\n";
    $msg2 .= "E-Mail Address : ".$Email_Address."\n";

    if(mail($To_Address, $Subject, $msg, $headers))
    {



    if(mail($Email_Address, $Subject2, $msg2, $headers2))
    {
    if(mail($customeremail, $Subject1, $msg1, $headers1));
    /* if(file_exists($Image)){ */
    {

    Echo "<br><br><br><br>The information has been submitted successfully.<br>The confirmation e-mail has been sent to the specified e-mail address.<br>If you would like to send other pictures, please <a href=submitphototest.php?runprogram=cont&Dealership_Realtor_Name=".str_replace(" ","%20",$Dealership_Realtor_Name)."&Submitted_By=".str_replace(" ", "%20",$Submitted_By)."&Email_Address=".$Email_Address.">click here</a>.";




    }

    }

    }
    else
    { echo "<br><br><br><br>Information could not be sent.<br>Please <a href=submitphototest.php?runprogram=cont&Dealership_Realtor_Name=".str_replace(" ","%20",$Dealership_Realtor_Name)."&Submitted_By=".str_replace(" ", "%20",$Submitted_By)."&Email_Address=".$Email_Address.">click here</a> and try again. ";
    }
    }elseif($_GET['runprogram'] = 'cont')
    {

    ?>

    Thanks,
    Peggy

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Where is $customeremail_exist defined? And what does it contain? I think you want something like if($_POST['customeremail'] != '')
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    PHP Code:
    if(!empty($customeremail)){

    blah blah your stuff goes here




  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •