Announcement

Collapse
No announcement yet.

strange happening with form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • strange happening with form

    I have created a php form to process an email form. The form works but the from field is incorrect in the email.

    The variable $fldfrom contains the value for the from field. In the body of the message I have the variable's value displayed and the value is correct but the sender value in the email is incorrect and it lists a email that is used on one of my domains in my hosting account but is not listed on the form anywhere.

    Any ideas what may be going on?

    Thanks

    Below is the code.

    Code:
    <?php
    include("global.inc.php");
    $errors=0;
    $error="The following errors occured while processing your form input.<ul>";
    pt_register('POST','fldto');
    pt_register('POST','fldfrom');
    pt_register('POST','fldsubject');
    pt_register('POST','fldmemo');
    $fldmemo=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $fldmemo);if($fldto=="" || $fldfrom=="" || $fldsubject=="" || $fldmemo=="" ){
    $errors=1;
    $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
    }
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$fldfrom)){
    $error.="<li>Invalid email address entered";
    $errors=1;
    }
    if($errors==1) echo $error;
    else{
    	switch($fldto){
    		case 'Sales':
    		$fldtoemail='frrobert@batushkas.com';
    		break;
    		case 'Customer Service':
    		$fldtoemail='frrobert@batushkas.com';
    		break;
    		}
    $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
    $message="fldto: ".$fldto."
    fldfrom: ".$fldfrom."
    fldsubject: ".$fldsubject."
    fldmemo: ".$fldmemo."
    ";
    $message = stripslashes($message);
    mail($fldtoemail, $fldsubject ,$message, $fldfrom);
    
    header("Refresh: 0;url=http://www.batushkas.com");
    ?><?php 
    }
    ?>

  • #2
    Found the problem had the header setting incorrect had to add a line and modify one line

    $headers = 'From: '. $fldfrom . "\r\n";
    mail($fldtoemail, $fldsubject ,$message, $headers);

    Comment

    Working...
    X