I have the following PHP contact form that has CAPTCHA code to make sure it is correct. However, when I reply to the email from the website, it puts a random email, which I believe is the server administrator, however I want it to be the email address that sent the form. Below is the code, maybe you can help me?
<?php session_start(); if(isset($_POST['Submit'])) { if( $_SESSION['chapcha_code'] == $_POST['chapcha_code'] && !empty($_SESSION['chapcha_code'] ) ) { $youremail = ' info@domain.com '; $fromsubject = 'www.domain.co.uk'; $title = $_POST['title']; $fname = $_POST['fname']; $mail = $_POST['mail']; $phone = $_POST['phone']; $subject = $_POST['subject']; $message = $_POST['message']; $to = $youremail; $mailsubject = 'Message from Website'.$fromsubject.' Contact Page'; $body = $fromsubject.' The person that contacted you is: '.$fname.' Phone Number: '.$phone.' E-mail: '.$mail.' Subject: '.$subject.' Message: '.$message.' |---------END MESSAGE----------|'; echo "Thank you for your message. I will contact you shortly if needed.<br/> Go to <a href='/index.html'>Home Page</a>"; mail($to, $subject, $body); unset($_SESSION['chapcha_code']); } else { echo 'Sorry, you have provided an invalid security code'; } } else { echo "You must write a message. </br> Please go to <a href='/contact.html'>Contact Page</a>"; } ?>
I was told to attach the following to the code, but where to put it?
$headers = "From: $mail\r\n"; $headers .= "Reply-To: $mail\r\n"; mail($to, $subject,$body,$headers);
Thank you very much
GS computers
source share