All of my form works well, the only thing i,m trying to achieve is combine the first_name with last_name to give full name in the email header. I'm using PHPMailer. This is the code i tried to use -

$firstname = $POST["first_name"];
$lastname = $
POST["last_name"];
$fullname = $firstname . ' ' . $lastname;
$fullname = $_POST["name"];

$mail = new PHPMailer(TRUE);
$mail->From = $POST["email"]; //Sets the From email address for the
message
$mail->FromName = $
POST["name"]; //Sets the From name of the message
$mail->AddAddress('timmy2872@gmail.com'); //Adds a "To" address
$mail->WordWrap = 50; //Sets word wrapping on the body of the
message to a given number of characters
$mail->IsHTML(true); //Sets message type to HTML
$mail->AddAttachment($path); //Adds an attachment from a path on the
filesystem
$mail->Subject = 'Employer Application Form details'; //Sets the
Subject of the message
$mail->Body = $message; //An HTML or plain text message body
if($mail->Send()) //Send an Email. Return true on success or
false on error

Can anyone see what i,m doing wrong??

    $fullname = $firstname . ' ' . $lastname;
    $fullname = $_POST["name"];

    You put $firstname and $lastname together and then immediately throw away the result and replace it with $_POST["name"].

    Weedpacket I tried posting $fullname in $mail->FromName = $fullname;
    But that doesn't work either?

      So tried this now and still no luck -

      $firstname = $POST["first_name"];
      $lastname = $
      POST["last_name"];
      $_POST["full_name"] = $firstname . ' ' . $lastname;

      $mail = new PHPMailer(TRUE);
      $mail->From = $POST["email"]; //Sets the From email address for the message
      $mail->FromName = $
      POST["full_name"];

        To store the combination of the first name and last name, just use a simple variable to refer to the full name, e.g.,

        // Check that $_POST["first_name"] and $_POST["last_name"] exist and validate them:
        // ...
        // Now construct the full name:
        $full_name = $_POST["first_name"] . ' ' . $_POST["last_name"]

        Then later you can use:

        $mail->FromName = $full_name;

        Actually, you don't even need $full_name because you can set $mail->FromName directly, but it may be clearer and you might want to do other things with the user's full name.

        laserlight Thanks Laserlight, but unfortunately that didn't work either, still just shows the email address. Any other ideas, as i,m really scratching my head over this one.

          laserlight Laserlight you were absolutely right it works, the reason it was throwing me off course was when i enter my email address into the field when it arrives in my inbox it was showing just the email address as my email address shows as "me" when i enter someone elses email it comes up with there first and last name. Thank you very much indeed for sorting this problem out for me 💯

            Write a Reply...