提交了我的php表单,但没有一个值被发送 [英] submitted my php form, but none of the values were sent

查看:81
本文介绍了提交了我的php表单,但没有一个值被发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,我的电子邮件中没有显示这些选项。我可以收到发送的电子邮件。我可以看到身体和它的所有评论,但没有用户提供的条目。我知道我做错了事情,但我无法确定是什么。

For some reason, the options are not showing up in my email. I can get the email to send just fine. I can see the body and all its comments, but none of the entries that the user made. I know I am doing something wrong, but I cannot determine what it is.

此外,如果看起来很可怕,请随时嘲笑我。 :)


Also, feel free to mock me if it looks horrible. :)

$ToEmail = 'dmandrade1978@gmail.com'; 
$EmailSubject = 'Message from web page!!'; 

$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$urphone = $_POST['urphone'];
$event = $_POST['event'];
$date = $_POST['date'];
$mail = $_POST['mail'];
$phone = $_POST['phone'];
$comment = $_POST['comment'];
$hearaboutus = $_POST['hearaboutus'];

$body = <<<EMAIL
Email: $email <br />
Name: $name <br />
Comment: $comment <br />
Phone: $urphone <br />
Date: $urdate <br />
Comment: $comment <br />
How did you hear?: $hearaboutus <br />
Mail optiom: $mail <br />
EMAIL;

$header = "Content-type: text/html\r\n";
mail("$ToEmail", "$EmailSubject", "$body", "$header");
echo ("Message Sent!");

?>

<td class = "form">
<form action="?" method="get" enctype="text/plain">
<p class = "form">Name:<br />
<input type="text" name="name" id="name" /></p>
<p class = "form">E-mail:<br />
<input type="text" name="email" id="email" /></p>
<p class = "form">Phone #:<br />
<input type="text" name="urphone" id="urphone" /></p>
<p class = "form">Event type:<br />
<input type="text" name="event" id="event" /></p>
<p class = "form">Date of event:<br />
<input type="text" name="date" id="date" /></p>
<p class = "form" >Prefered method of contact:<br />
<span class = "contact">
<input type="radio" name="phone" id="phone" /> Phone<br />
<input type="radio" name="mail" id="mail" /> E-mail<br />
</span></p>
<p class = "form">How did you hear about us?:<br />
<select name="hearaboutus" id="hearaboutus" />
<option value="internet">Internet</option>
<option value="word of mouth">Friend/Family</option>
<option value="magazine">Magazine</option>
<option value="other">Other</option>
</select></p>
<p class = "form">Message, questions, or availability:<br />
<textarea rows="10" cols="30" name="comment" id="comment">
</textarea></p>
<input type="submit" value="Send email to us" id="submit">
<input type="reset" value="Reset and start over">
</form>


推荐答案

更改 method =get

to

method =post

并删除 enctype 。在这种情况下不需要。

and remove enctype . It's not required in this case.

另外,为什么您的操作中有一个?您可以在发布到同一页面时将动作保持空白。

Also, why is there a ? in your action? You can keep action blank as it is posting to the same page.

为了使事情变得更加简单,请复制粘贴以下代码并再次运行文件

To make things even simpler for you, copy paste the below code and run the file again

if(isset($_POST['submit']))
{
$ToEmail = 'dmandrade1978@gmail.com'; 
$EmailSubject = 'Message from web page!!'; 

$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$urphone = $_POST['urphone'];
$event = $_POST['event'];
$date = $_POST['date'];
$mail = $_POST['mail'];
$phone = $_POST['phone'];
$comment = $_POST['comment'];
$hearaboutus = $_POST['hearaboutus'];

$body = <<<EMAIL
Email: $email <br />
Name: $name <br />
Comment: $comment <br />
Phone: $urphone <br />
Date: $urdate <br />
Comment: $comment <br />
How did you hear?: $hearaboutus <br />
Mail optiom: $mail <br />
EMAIL;

$header = "Content-type: text/html\r\n";
mail("$ToEmail", "$EmailSubject", "$body", "$header");
echo ("Message Sent!");
}
?>

<td class = "form">
<form action="" method="post">
<p class = "form">Name:<br />
<input type="text" name="name" id="name" /></p>
<p class = "form">E-mail:<br />
<input type="text" name="email" id="email" /></p>
<p class = "form">Phone #:<br />
<input type="text" name="urphone" id="urphone" /></p>
<p class = "form">Event type:<br />
<input type="text" name="event" id="event" /></p>
<p class = "form">Date of event:<br />
<input type="text" name="date" id="date" /></p>
<p class = "form" >Prefered method of contact:<br />
<span class = "contact">
<input type="radio" name="phone" id="phone" /> Phone<br />
<input type="radio" name="mail" id="mail" /> E-mail<br />
</span></p>
<p class = "form">How did you hear about us?:<br />
<select name="hearaboutus" id="hearaboutus" />
<option value="internet">Internet</option>
<option value="word of mouth">Friend/Family</option>
<option value="magazine">Magazine</option>
<option value="other">Other</option>
</select></p>
<p class = "form">Message, questions, or availability:<br />
<textarea rows="10" cols="30" name="comment" id="comment">
</textarea></p>
<input type="submit" name="submit" value="Send email to us" id="submit">
<input type="reset" value="Reset and start over">
</form>

这篇关于提交了我的php表单,但没有一个值被发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆