Need Little Help with PHP...

Discussion in 'PHP' started by SunnyBeach, Apr 21, 2012.

  1. #1
    Could you please tell me how to change the php code for the contact form below? 1. I need the sender's email to populate the address field so that when I hit reply (after I receive their email message), the sender's email address is in the reply field instead of webmaster@example.com?2. If possible, I would also like the sender's email that they type in to show up in my email box so that it shows from the person's email that sent the email in the from column in my email box instead of webmaster@example.com?Thank you for any help.I can't post the code. How do I disply the code for you to see?
     
    Last edited: Apr 21, 2012
    SunnyBeach, Apr 21, 2012 IP
  2. SunnyBeach

    SunnyBeach Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Code attached because I can't include it in post.
     

    Attached Files:

    SunnyBeach, Apr 21, 2012 IP
  3. weisheng

    weisheng Member

    Messages:
    406
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #3
    I use the same script but hit reply it does not appear
     
    weisheng, Apr 21, 2012 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    I'm assuming the sender of the email inputs their own email somewhere in the form which populates this PHP-scrpt. Simply exchange the with the variable containing the user's email.

    As it is in the script you sent, you replace this:
    $headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    Code (markup):
    with
    $headers = 'From: '.$variable_with_user_email.'' . "\r\n" .
    'Reply-To: '.$variable_with_user_email.'' . "\r\n" .
    Code (markup):
     
    PoPSiCLe, Apr 22, 2012 IP
  5. SunnyBeach

    SunnyBeach Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for the responses. PoPSiCLe, appreciate the code. Sorry I can't paste code directly into this message so I attached the changed code (which may or may not be the correct code changes).I changed the code like you said and it seems to work .When I receive the email sent from the contact line, on the From: line, it lists the person's name that completed the form in the From box and unfortunately following the name that the person typed in, l it lists my main hosting account name & hosting company instead of the domain that the contact form is associated with. How can I change the code to list the domain this form is in on or how can I remove it completely from populating the From: line? I pasted the From line from the email received below; hopefully, the line will show in this message. From: namefilledputonform < mainhostingaccount @ host910.hostingcompany. com> There is also a contact_form.js file if you need to see it. If you like, I'll send you some payment via PayPal for your help. Thanks again.
     

    Attached Files:

    SunnyBeach, Apr 22, 2012 IP
  6. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #6
    PoPSiCLe, Apr 22, 2012 IP
  7. Arttu

    Arttu Member

    Messages:
    139
    Likes Received:
    2
    Best Answers:
    8
    Trophy Points:
    40
    #7
    Replace
    $headers = 'From: '.$_POST['name'].'' . "\r\n" .
    with
    $headers = 'From: "'.$_POST['name'].'" <' . $_POST['email'] . ">\r\n" .

    if this doesn't work then your host doesn't allow sending mail as fake addresses.
     
    Arttu, Apr 23, 2012 IP
  8. SunnyBeach

    SunnyBeach Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Arttu,That's perfect! Thank you for your help!
     
    SunnyBeach, Apr 24, 2012 IP