baudits Posted June 24, 2010 Share Posted June 24, 2010 Hello. Im new to PHP and I have made a mail form for my site. My problem is I can't see the senders e-mail when im receiving an e-mail. Does anyone have an idea what the problem is? Thanks. The code look like this: <form method="post" action="contact.php"> Enter your Name:<br> <input name="name" type="text"><br> E-mail:<br> <input name="email" type="text"><br> Subject:<br> <input name="subject" type="text"><br> Enter your Message:<br> <textarea name="message" rows="15" cols="40"></textarea><br> <input type="submit"> </form> <?php $to = "[email protected]"; /*$to = "[email protected]";*/ $subject = $_REQUEST['subject']; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $name = $_REQUEST['name'] ; $headers = "From: $email"; if(preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email)) { print "We encountered an error sending your mail"; } else if (empty($email) || empty($message)) { print "You must enter a message and your E-mail"; } else { /*$sent = mail($to, $subject, $message, $name, $email) ;*/ $sent = mail($to, $subject, $message, $name, $headers) ; if($sent) { print "Your mail was sent successfully"; } else { print "We encountered an error sending your mail 2"; } } ?> Link to comment https://forums.phpfreaks.com/topic/205741-mail-form-troubles-cant-see-the-sender/ Share on other sites More sharing options...
kenrbnsn Posted June 24, 2010 Share Posted June 24, 2010 You are using the mail function incorrectly. The format is <?php mail($to,$subject,$body,$headers,$extra_headers); ?> The $extra_headers & $headers variables are optional, but most people use the $headers variable. Read the manual. Ken Link to comment https://forums.phpfreaks.com/topic/205741-mail-form-troubles-cant-see-the-sender/#findComment-1076621 Share on other sites More sharing options...
baudits Posted June 26, 2010 Author Share Posted June 26, 2010 Thanks alot. Link to comment https://forums.phpfreaks.com/topic/205741-mail-form-troubles-cant-see-the-sender/#findComment-1077570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.