Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

How to modify php form processing script for localhost

Avatar of Jack Andrews
Jack AndrewsFlag for United States of America asked on
PHPEmail ServersEmail Protocols
6 Comments1 Solution543 ViewsLast Modified:
I manage a site that has an MX pointing to a remote server for email.

Problem: A form on the web site is intermittantly not sending mail to the form owner from the site. I think the issue might be the remote email server at the former hosting service.

Until we can move these emails over to the web host's server, I am told I can make a change in the php processor for the form to add localhost that makes the email send through the site host server. If this is true, how and where would I do that? I do not write php.

Or if there is a better solution, what would that be? Here is the current processor. I deleted commented out code and changed stuff for security purposes:

<?

include("./wp-config.php");

$frm_server_side_error="";

$error="";

function check_email($email){

      $Result = eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);

      if ($Result)

            return TRUE;

      else

            return FALSE;

}

function check_text($textbox){      

      if ((trim($textbox) != "")){

            return true;

      }      

      else{

            return false;

      }            

}

function check_integer($int){

      $Result = eregi("^[0-9]*$", $int);

      if ($Result)

            return TRUE;

      else

            return FALSE;

}      



if(isset($_REQUEST[sendbutton])){

   $frm_path = $_REQUEST[frm_path];

   $first_name = $_REQUEST[cf_field_2];

   $last_name = $_REQUEST[frm_last];

   $email = $_REQUEST[cf_field_3];

   $phone1 = $_REQUEST[frm_phone1];

   $phone2 = $_REQUEST[frm_phone2];

   $phone3 = $_REQUEST[frm_phone3];

   $phone = $phone1."-".$phone2."-".$phone3;

   

   

  $move_in_date = $_REQUEST[cf_field_6];

   

 

         if(!check_text($_REQUEST[cf_field_2])){

                  $frm_server_side_error = "First Name,";

            }      

          if(!check_text($_REQUEST[frm_phone1])){

                  $frm_server_side_error = $frm_server_side_error."Phone1,";      

            }else{

               if(!check_integer($_REQUEST[frm_phone1])){

                 $frm_server_side_error = $frm_server_side_error."Phone1,";

               }

            }

            

            if(!check_text($_REQUEST[frm_phone2])){

                  $frm_server_side_error = $frm_server_side_error."Phone2,";      

            }else{

               if(!check_integer($_REQUEST[frm_phone2])){

                 $frm_server_side_error = $frm_server_side_error."Phone2,";

               }

            }

            if(!check_text($_REQUEST[frm_phone3])){

                  $frm_server_side_error = $frm_server_side_error."Phone3,";      

            }else{

               if(!check_integer($_REQUEST[frm_phone3])){

                 $frm_server_side_error = $frm_server_side_error."Phone1,";

               }

            }

            if(!check_text($email)){

                     $frm_server_side_error.='Email,';

                     $flag = true;       

          }

            if(check_text($email)){

                  if(!check_email($email)){

                         $frm_server_side_error = $frm_server_side_error."Email,";

                  }

            }

      

   $count=30;

   for($i=0;$i<=$count;$i++){

            if(!$_POST[cf_field_7][$i] == ""){

                  $edit_check_city.= $_POST[cf_field_7][$i].",";

            }

      }            

   $lease_term = $_REQUEST[cf_field_8];

   $bedrooms = $_REQUEST[cf_field_9];

   $bath_rooms = $_REQUEST[cf_field_10];

   $max_rent = $_REQUEST[cf_field_11];

   $count_am=24;

   for($k=0;$k<=$count_am;$k++){

            if(!$_POST[cf_field_12][$k] == ""){

                  $edit_check_amenity.= $_POST[cf_field_12][$k].",";

            }

      }            

   

   $additional_notes = $_REQUEST[cf_field_13];

   

   if($frm_server_side_error==""){

            $sql_email_check = "select * from tbl_search_details where str_email ='$email'";

            $rs_email_check = mysql_query($sql_email_check);

                         

             if(mysql_num_rows($rs_email_check)<1){

                  header("Location: http://www.domain/folder");

             }else{      

                        $sql_insert= "insert into tbl_search_details ( str_first_name , str_last_name, str_email , str_phone , str_movein_date , bit_active ) values ('$first_name', '$last_name', '$email', '$phone', '$move_in_date','1')";

                      $rs_insert = mysql_query($sql_insert) or die(mysql_error());

                      $today = date("Y-m-d");

                        list($job_year,$job_month,$job_day)=split("-", $today);

                        $month = date(M,mktime(0,0,0,$job_month,$job_day,$job_year));

                    $ip = $_SERVER['REMOTE_ADDR'];

                        $mail_to = "email1@gmail.com,email2@email.com";

                        $mail_subject= "User Registration from Site ";

                        $mail_body = "<table style=font:Verdana; font-size:10px;  border=0 cellspacing=0 cellpadding=2 width=700><tr ><td height=25 colspan=2 style='color:#7d7d7d;font-family:tahoma;font-size:13px;' align='right'>a form has been submitted on $month $job_day, $job_year via: /contact[IP $ip]</td></tr></table>";

                        $mail_body = $mail_body ."<table style=font:Verdana; font-size:10px;  border=0 cellspacing=0 cellpadding=1 width=700><tr bgcolor=#eff0fa><td height=25 colspan=2 style='color:#7d7d7d;font-family:tahoma;font-size:13px;'>BEGIN YOUR FREE SEARCH</td></tr>";

                        $mail_body = $mail_body ."<tr bgcolor=#e6e8f7><td height=1 colspan=2></td></tr><tr bgcolor=#f4f5fb><td style='font-family:arial,tahoma;font-size:12px;color=#6c6c6c;' width=30%'>";

                        $mail_body = $mail_body ."Name:</td><td style='font-family:arial,tahoma;font-size:12px;color:#7d7d7d;' width=70%>$first_name $last_name</td></tr>";

                        $mail_body = $mail_body ."<tr bgcolor=#f4f5fb><td style='font-family:arial,tahoma;font-size:12px;color=#6c6c6c;' height=25>Email:</td><td style='font-family:arial,tahoma;font-size:12px;color:#7d7d7d;'>$email</td></tr>";

                        $mail_body = $mail_body ."<tr bgcolor=#f4f5fb><td style='font-family:arial,tahoma;font-size:12px;color=#6c6c6c;' height=25>Phone:</td><td style='font-family:arial,tahoma;font-size:12px;color:#7d7d7d;'>$phone</td></tr>";

                        $mail_body = $mail_body ."<tr bgcolor=#f4f5fb><td style='font-family:arial,tahoma;font-size:12px;color=#6c6c6c;' height=25>Move In Date:</td><td style='font-family:arial,tahoma;font-size:12px;color:#7d7d7d;'>$move_in_date</td></tr>";

                        $mail_body = $mail_body ."<tr bgcolor=#f4f5fb><td style='font-family:arial,tahoma;font-size:12px;color=#6c6c6c;' height=25>Preferred Cities:</td><td style='font-family:arial,tahoma;font-size:12px;color:#7d7d7d;'>$edit_check_city</td></tr>";

                        $mail_body = $mail_body ."<tr bgcolor=#f4f5fb><td style='font-family:arial,tahoma;font-size:12px;color=#6c6c6c;' height=25>Lease Term:</td><td style='font-family:arial,tahoma;font-size:12px;color:#7d7d7d;'>$lease_term</td></tr>";

                        $mail_body = $mail_body ."<tr bgcolor=#f4f5fb><td style='font-family:arial,tahoma;font-size:12px;color=#6c6c6c;' height=25>Bedrooms:</td><td style='font-family:arial,tahoma;font-size:12px;color:#7d7d7d;'>$bedrooms</td></tr>";

                        $mail_body = $mail_body ."<tr bgcolor=#f4f5fb><td style='font-family:arial,tahoma;font-size:12px;color=#6c6c6c;' height=25>Bathrooms:</td><td style='font-family:arial,tahoma;font-size:12px;color:#7d7d7d;'>$bath_rooms</td></tr>";

                        $mail_body = $mail_body ."<tr bgcolor=#f4f5fb><td style='font-family:arial,tahoma;font-size:12px;color=#6c6c6c;' height=25>Max Rent:</td><td style='font-family:arial,tahoma;font-size:12px;color:#7d7d7d;'>$max_rent</td></tr>";

                        $mail_body = $mail_body ."<tr bgcolor=#f4f5fb><td style='font-family:arial,tahoma;font-size:12px;color=#6c6c6c;' height=25>Desired Amenities:</td><td style='font-family:arial,tahoma;font-size:12px;color:#7d7d7d;'>$edit_check_amenity</td></tr>";

                        $mail_body = $mail_body ."<tr bgcolor=#f4f5fb><td style='font-family:arial,tahoma;font-size:12px;color=#6c6c6c;' height=25>Additional Notes:</td><td style='font-family:arial,tahoma;font-size:12px;color:#7d7d7d;'>$additional_notes</td></tr>";

                        $mail_body = $mail_body ."<tr bgcolor=#f4f5fb><td style='font-family:arial,tahoma;font-size:12px;color=#6c6c6c;' height=25>Referrel URL:</td><td style='font-family:arial,tahoma;font-size:12px;color:#7d7d7d;'>$frm_path</td></tr>";

                        $mail_body = $mail_body ."</td></tr><tr><td align='left'><br><a href='http://www.domain.com'>www.domain.com</a></td></tr></table>";

                        $headers =  "Content-Type: text/html;charset=iso-8859-1\n";

                        $headers = $headers . "From:".$email."";

                        //die($mail_body);

                        mail($mail_to,$mail_subject,$mail_body,$headers);

                        header("Location: http://www.domain.com/folder");

                  }
   }

}?>
ASKER CERTIFIED SOLUTION
Avatar of Jack Andrews
Jack AndrewsFlag of United States of America image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers