Jump to content

Recommended Posts

Posted

Hello,

 

I have created a web form to allow parents and other visitors to the site to send a message to the secretary. At the moment all is working fine except one thing.

 

I have set up a box for email address which should then be provided as the return address. But this is not the case. Since the php mail function is running on the webserver and the server is also the smtp sender then the reply address is set as the servers address.

 

how can i set the reply address to the senders address that they put in the box.

 

I have sent the form using the post method into a .php page which then sends the info and echo a success message or failure message to screen.

 

The email field has the label of contact_email and the name is Email.

 

There is a javascript variable set by the contents of this field which is used for validation.

 

I have a variable set on the php side $email = $-REQUEST['email']; which is used in the send command. I have tried to use the same variable in the headers reply to section but this does not work.

what can i do to try and resolve this problem?

Posted

I use the following code for my contact form. When I receive an email the from address is the email address that the person specified when completing the form. I am not a PHP developer so I can't help you much but you might be able to work it out from my code.

 


   if($_POST['submit']){
   
     $name = $_REQUEST['name'] ; 
     $email = $_REQUEST['email'] ; 
     $message = $_REQUEST['message'] ; 
   
     if($name == '' || $email == '' || $message == ''){
       $comment = 'All of the fields need to be completed!';
     }
     elseif(!eregi("^[0-9a-z]([-_.~]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$email)){
       $comment = 'The e-mail address you have entered is invalid!';
     }
     else
     {
             mail( "Email address", "Subject", $message, "From: $email" ); 
         header( "Location: ?sent=yes" ); 
     }
   }
?> 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...