开发者

My PHP contact form is shooting blanks

Please forgive the tongue-in-cheek title, but I've been trying for the last hour to get my contact form to work properly. It sends the email just fine but it leaves out all the relevant data (name, email, etc.)

I've modified a PHP contact form tutorial, but I don't know where I've gone wrong.

The HTML:

<form name="form1" method="post" action="send_contact.php">
<fieldset>
    <h3>Name</h3>
    <input name="name" type="text" id="name">

    <h3>Email (required)</h3>
    <input name="email" type="text" id="email">

    <h3>Phone (required)</h3>
    <input name="telephone" type="text" id="telephone">

    <h3>Desired appointment time/date</h3>
    <input name="time" type="text" id="time">

    <input type="submit" name="Submit" value="Submit">

</fieldset>
</form>

The PHP:

&开发者_JS百科lt;?php
// customer name
$customer_name = "$name";
// customer email
$mail_from = "$email";
// customer telephone
$customer_telephone = "$telephone";
// desired appointment time
$appointment_time = "$time";

// subject
$subject = "Appointment for $customer_name";
// message
$message = "$customer_name would like to book an appointment for $appointment_time";
// header
$header = "from: $customer_name <$mail_from>";
// recipient
$to = 'my@emailaddress.com'; 

$send_contact = mail($to,$subject,$message,$header);

if($send_contact){
    echo "We've recived your contact information";
}
else {
    echo "ERROR";
}
?>


You don't need quotes.

$customer_name = "$name";
$customer_name = $name;

You should really use post to grab the data.

$customer_name = $_POST['name'];


you need to be looking in the super global $_POST for your variables. for example

$customer_name = $_POST['name'];


if your posting the data you need to get it from the post: I would trim it also

$customer_name = trim( $_POST['name'] );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜