dandymandy Posted February 14, 2014 Share Posted February 14, 2014 Hello, I've designed a simple form to accept user input for our contact page. It sends the email, but doesn't pass the information from my form. So for example, the email subject says: Request More Information and the body of the email will look like this (no actual information from the form): Name: Email: Phone: Company: Location: Message: I'm at a loss and could really use some input. Thanks. Here's my PHP: <?php if($_SERVER['REQUEST_METHOD'] == "POST"){ $subject = "Request More Information"; $mail_to = '[email protected]'; /* These will gather what the user has typed into the field. */ $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $company = $_POST['company']; $location = $_POST['location']; $message = $_POST['message']; $message = wordwrap($message, 70); /* This takes the information and lines it up the way you want it to be sent in the email. */ $body = " Name: $name \n\r Email: $email \n\r Phone: $phone \n\r Company: $company \n\r Location: $location \n\r Message: $message \n\r"; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($mail_to, $subject, $body, $headers); } ?> And additionally my form html: <form action="form_mailer2.php" method="POST" enctype="text/plain"> Name*<br /> <input type="text" name="name" style="width: 195px" /><br /> Email*<br /> <input name="email" style="width: 195px" type="text" /><br /> Phone*<br /> <input name="phone" style="width: 195px" type="text" /><br /> Company<br /> <input name="company" style="width: 195px" type="text" /><br /> Location<br /> <input name="location" style="width: 195px" type="text" /><br /> Message*<br /> <textarea name="message" style="height: 75px; width: 195px" cols="20"></textarea><br /> <input name="submit" value="submit" type="image" src="images/send_button.png" style= "margin-left: 60px; padding: 6px;"/> </form> Link to comment https://forums.phpfreaks.com/topic/286207-php-mail-form-sends-emails-with-blank-variables/ Share on other sites More sharing options...
.josh Posted February 14, 2014 Share Posted February 14, 2014 remove enctype="text/plain" Link to comment https://forums.phpfreaks.com/topic/286207-php-mail-form-sends-emails-with-blank-variables/#findComment-1468945 Share on other sites More sharing options...
dandymandy Posted February 14, 2014 Author Share Posted February 14, 2014 Thank you! Completely fixed my problem. Link to comment https://forums.phpfreaks.com/topic/286207-php-mail-form-sends-emails-with-blank-variables/#findComment-1468950 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.