PHP form submission script issue

THUNDERPOWER

New Member
Reaction score
1
I have a PHP script that emails me the form the user fills-in on my website. The problem is, when I receive the email, the sender (person who filled in the form) does not get a confirmation email like they should. This is because the sender's name/email end up mixed up.

Example 1:

Example1.png

"[email protected]" is the sender's email. As you can see in the grey square brackets, the email address ends up being mixed up with the sender's name.

This is the script used for Example 1:

Code:
<?
       $sfname = $_POST['firstname'];
       $slname = $_POST['lastname'];
       $ssex = $_POST['sex'];
       $semail = $_POST['email'];
       $shome = $_POST['home'];
       $scell = $_POST['cell'];
       $sstreet = $_POST['street'];
       $scity = $_POST['city'];
       $spostcode = $_POST['postcode'];
       $sprovince = $_POST['province'];
       $scountry = $_POST['country'];
       $sposition = $_POST['position'];
       $sheard = $_POST['heard'];
       $scrime = $_POST['crime'];
       $swork = $_POST['work'];
       $sresume = $_POST['resume'];
       $sreference = $_POST['reference'];
       $msg = "First Name: $sfname\nLast name: $slname\nSex: $ssex\nEmail: $semail\nHome Tel: $shome\nCell No: $scell\nStreet: $sstreet\nCity: $scity\nPostcode: $spostcode\nProvince: $sprovince\nCountry: $scountry\nPosition Applied for: $sposition\nHead About us: $sheard\nConvicted of Crime: $scrime\nEntitled to work: $swork\nResume: $sresume\n References: $sreference\n";

$recipient = "[email protected]";
$subject = "Job Application Form";

$mailheaders = "From:$sfname $slname";
$mailheaders .= "Reply-To:".$_POST['email'];


mail($recipient, $subject, $msg, $mailheaders);
header("Location:success.html");
?>

Example 2:

Now, if I change
Code:
$mailheaders = "From:$sfname $slname";
$mailheaders .= "Reply-To:".$_POST['email'];
from the code above to
Code:
$mailheaders .= $_POST['email'];
, I will get this:

Example2.png

As you can see from Example 2, the sender's email will display my server's email instead causing the REAL sender not to receive my confirmation email.

This is a very big problem and I need to change it so that the sender WILL receive a confirmation email by acquiring the right email address from the form.
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
English plz. :p What do I need to change?

This line won't work:

Code:
$mailheaders = "From:$sfname $slname";

You can't send it from a first name then a last name. An acceptable "from" field would be:

Code:
$mailheaders = "From:$sfname $slname <$semail>";
 

THUNDERPOWER

New Member
Reaction score
1
This is what I get now:

Example3.png


The email address in the brackets is definitely right this time, but for some reason, my auto-responder is not auto-replying to the message. I tried sending a normal email to it, and it worked, but not when I submit the form. Why is that?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top