Jump to content

PHP mail() form sends emails with blank variables


dandymandy
Go to solution Solved by .josh,

Recommended Posts

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 = 'info@specialtycs.com';

/* 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.