I need a little help. I am trying to get my PHP code (saved as a separate file named lulzy.php) to work but it just doesn't want to. What is it that I am doing wrong???
我需要一些帮助。我试图让我的PHP代码(保存为一个名为lulzy.php的单独文件)工作,但它只是不想。我做错了什么???
My goal is to get the users message directly into my e-mail inbox and right upon the user fills out my web form.
我的目标是将用户消息直接发送到我的电子邮件收件箱中,直到用户填写我的网络表单。
Here is the link to my JSFiddle: http://jsfiddle.net/8S82T/127/
这是我的JSFiddle的链接:http://jsfiddle.net/8S82T/127/
And here is my PHP code:
这是我的PHP代码:
<?php
$name= $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
mail( "mymail@gmail.com", "Feedback Form Results",
$message, "From: $email" );
header( 'Location: Index.html' );
?>
Everything is in the same folder on my desktop.
一切都在我桌面上的同一个文件夹中。
This is the message I receive when I try to fill the whole form and send a message:
这是我在尝试填写整个表单并发送消息时收到的消息:
Firefox can't find the file at /C:/Users/MS/Desktop/Slide Down Contact Me Form/lulzy.php
Firefox无法在/ C:/ Users / MS / Desktop / Slide Down Contact Me Form / lulzy.php中找到该文件
4 个解决方案
#1
1
I think none of the answers here contain the actual solution for this error message:
我认为这里没有任何答案包含此错误消息的实际解决方案:
Firefox can't find the file at /C:/Users/MS/Desktop/Slide Down Contact Me Form/lulzy.php
Firefox无法在/ C:/ Users / MS / Desktop / Slide Down Contact Me Form / lulzy.php中找到该文件
This implies that
这意味着
- you have opened your HTML from your local hard drive (instead of serving it from a local web server)
- 您已从本地硬盘驱动器打开HTML(而不是从本地Web服务器提供)
- and you therefore don't have any PHP processor in there (though lulzy.php seems really to be non-existent in the specified folder)
- 因此你没有任何PHP处理器(虽然lulzy.php似乎在指定的文件夹中不存在)
Furthermore, you forgot to add name
attributes to your form fields (as others have already mentioned here) and you declared the method attribute as the form's action by accident:
此外,您忘记在表单字段中添加名称属性(正如其他人已在此处提到的那样),并且您意外地将方法属性声明为表单的操作:
<form action="lulzy.php" action="post">
<!-- This should be right: -->
<form action="lulzy.php" method="post">
Use a captcha? (see OP's comment)
I would definitely add one if you keep your form sending direct emails. There are several libraries out there - depending on your traffic (private or commercial site?) - you might use reCAPTCHA. You could also roll your own, but better use intelligent questions or something only a human could solve instead of an image.
Nevertheless, you should also take your users into consideration. Possible spam beating vs. user experience.
A completely other option besides verifying human beings would be to not send the emails to your (personal) email address, save them to your database instead and create a simple notification system on your own. That way, you have more granular filter control.
#2
6
You need to have name attribute on each of your form input's
您需要在每个表单输入上都有name属性
<input type="text" name ="fullName" placeholder="Please enter your full name here" required />
Same for email
and textarea
, and method='post'
instead of action='post'
电子邮件和textarea相同,而method ='post'代替action ='post'
Your php needs to be on your server not on your desktop.
您的PHP需要在服务器上,而不是在桌面上。
#3
2
You need method="POST"
instead of action="post"
你需要method =“POST”而不是action =“post”
your declaring action twice and not declaring your method
at all of how the form is posting to your PHP script
您的声明操作两次,而不是完全声明您的方法如何将表单发布到您的PHP脚本
You also for your name attributes like the other answers state
你也为你的名字属性,如其他答案状态
#4
2
You forgot to add name attributes:
您忘了添加名称属性:
<form action="lulzy.php" method="post">
<h6><img src="img/person.png" alt="" /> Name</h6>
<input name="name" type="text" placeholder="Please enter your full name here" required />
<h6><img src="img/email.png" alt="" /> E-mail</h6>
<input name="email" type="email" placeholder="Please enter your e-mail address" required/>
<h6><img src="img/message.png" alt="" /> Message</h6>
<textarea name="message" placeholder="Type your message..." required/></textarea>
<input type="submit" value="Submit">
</form>
#1
1
I think none of the answers here contain the actual solution for this error message:
我认为这里没有任何答案包含此错误消息的实际解决方案:
Firefox can't find the file at /C:/Users/MS/Desktop/Slide Down Contact Me Form/lulzy.php
Firefox无法在/ C:/ Users / MS / Desktop / Slide Down Contact Me Form / lulzy.php中找到该文件
This implies that
这意味着
- you have opened your HTML from your local hard drive (instead of serving it from a local web server)
- 您已从本地硬盘驱动器打开HTML(而不是从本地Web服务器提供)
- and you therefore don't have any PHP processor in there (though lulzy.php seems really to be non-existent in the specified folder)
- 因此你没有任何PHP处理器(虽然lulzy.php似乎在指定的文件夹中不存在)
Furthermore, you forgot to add name
attributes to your form fields (as others have already mentioned here) and you declared the method attribute as the form's action by accident:
此外,您忘记在表单字段中添加名称属性(正如其他人已在此处提到的那样),并且您意外地将方法属性声明为表单的操作:
<form action="lulzy.php" action="post">
<!-- This should be right: -->
<form action="lulzy.php" method="post">
Use a captcha? (see OP's comment)
I would definitely add one if you keep your form sending direct emails. There are several libraries out there - depending on your traffic (private or commercial site?) - you might use reCAPTCHA. You could also roll your own, but better use intelligent questions or something only a human could solve instead of an image.
Nevertheless, you should also take your users into consideration. Possible spam beating vs. user experience.
A completely other option besides verifying human beings would be to not send the emails to your (personal) email address, save them to your database instead and create a simple notification system on your own. That way, you have more granular filter control.
#2
6
You need to have name attribute on each of your form input's
您需要在每个表单输入上都有name属性
<input type="text" name ="fullName" placeholder="Please enter your full name here" required />
Same for email
and textarea
, and method='post'
instead of action='post'
电子邮件和textarea相同,而method ='post'代替action ='post'
Your php needs to be on your server not on your desktop.
您的PHP需要在服务器上,而不是在桌面上。
#3
2
You need method="POST"
instead of action="post"
你需要method =“POST”而不是action =“post”
your declaring action twice and not declaring your method
at all of how the form is posting to your PHP script
您的声明操作两次,而不是完全声明您的方法如何将表单发布到您的PHP脚本
You also for your name attributes like the other answers state
你也为你的名字属性,如其他答案状态
#4
2
You forgot to add name attributes:
您忘了添加名称属性:
<form action="lulzy.php" method="post">
<h6><img src="img/person.png" alt="" /> Name</h6>
<input name="name" type="text" placeholder="Please enter your full name here" required />
<h6><img src="img/email.png" alt="" /> E-mail</h6>
<input name="email" type="email" placeholder="Please enter your e-mail address" required/>
<h6><img src="img/message.png" alt="" /> Message</h6>
<textarea name="message" placeholder="Type your message..." required/></textarea>
<input type="submit" value="Submit">
</form>