简体   繁体   中英

Mail Contact Form

What is wrong with this code? Here is the first page of the code:

<strong>Contact Form</strong><form name="form1" method="post" action="sendcontact.php">Subject:<input name="subject" type="text" id="subject" size="50">Detail:<textarea name="detail" cols="50" rows="4" id="detail"> </textarea>Name:<input name="name" type="text" id="name" size="50">Email:<input name="email" type="text" id="email" size="50"><input type="submit" name="Submit" value="Submit"><input type="reset" name="Submit2" value="Reset">

Here is the sendcontact.php page:

<?php $subject =$subject;$message =$detail;$mail_form =$email;$header ="from: $name<$mail_from>";mail("email@email.com",$subject,$message,$header);?>

To retrieve variables submitted from a POST form you must get their values from the $_POST array.

This should accomplish what you are after:

$subject = $_POST['subject'];
$message = $_POST['detail'];
$mail_from = $_POST['email'];
$header ="from: ".$_POST['name']."<$mail_from>";
mail("email@email.com",$subject,$message,$header);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM