表单在PHP中发送电子邮件,提供空值

时间:2016-01-30 11:38:51

标签: php forms

我尝试使用HTML表单发送包含PHP的电子邮件。

但是,当我收到电子邮件时,姓名和电子邮件字段始终为空,我只收到该消息。

这是表格代码:

SELECT * 
FROM tablename a
RIGHT OUTER JOIN tablename b ON b.subcat_id =1
AND a.subcat_id = b.subcat_id
WHERE a.subcat_id = 8
GROUP BY a.client_id

和PHP代码:

<form class="form" id="contact" action="form-to-email.php" method="post">
<input class="name" type="text" id="name" placeholder="Name" required>
<input class="email" type="email" id="email" placeholder="Email" required>
<input class="phone" type="text" id="phone" placeholder="Phone No:">
<textarea class="message" name="message" id="message" cols="30" rows="10"     placeholder="Message" required></textarea>
<input class="submit-btn" id="submitbtn" type="submit" value="SUBMIT">
</form>

2 个答案:

答案 0 :(得分:3)

<input class="name"...错误,应为<input name="WHATEVER"

输入上的name属性是您引用表单值的原因。

答案 1 :(得分:1)

您需要在$fs = fsockopen("website", 80); if (!$fs) { echo "$errstr ($errno)<br />\n"; } else { fwrite($fs, $req.$bdy); while(!feof($fs)) { $GLOBALS['s'] = fgets($fs); } } fclose($fs); $attr = $GLOBALS['s']->attributes(); // THIS DOES NOT WORK echo $attr['Day date']; // I CANNOT GET VALUE HERE 代码中添加name个属性,例如:

input

您可以在此处阅读更多内容:http://www.html-form-guide.com/contact-form/php-email-contact-form.html