按钮功能正常的问题. [英] Problem with proper function of a button.
问题描述
大家好.我的任务是创建一个联系我们"表单,用户可以在其中键入消息,单击按钮,然后将其发送到我的电子邮件中.
我所拥有的:
四个文件:
error_message.html-``糟糕,出了点问题''表格.
feedback_form.html-这包含我的实际表格.
send_mail.php -这是发送电子邮件的操作.
Thank_you.html-发送确认.
这是feedback_form.html
Hello everyone. My task is to create a ''Contact Us'' form where the users can type a message, click a button, and it will send it to my e-mail.
What I have:
four files:
error_message.html -- ''Oops, something went wrong'' form.
feedback_form.html -- This contains my actual form.
send_mail.php -- This is the action which would send the email.
thank_you.html -- Confirmation of the send.
Here is the feedback_form.html
<div class="main_body">
<p>Send Us Your Feedback!</p>
<form action="send_mail.php" method="post">
<table>
<tr>
<td>Email Adress:</td>
<td>
<input type="text" name="email_address" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Comments:</td>
<td>
<textarea rows="10" cols="50" name="comments"></textarea>
</td>
</tr>
<tr><td> </td>
<td>
<input type="submit" value="Submit" />
</td>
</tr>
</table>
</form>
</div>
现在,我想发生的就是运行send_mail.php:
Now, What I wanted to happen, was to run the send_mail.php:
<?php
/*
This first bit sets the email address that you want the form to be submitted to.
You will need to change this value to a valid email address that you can access.
*/
$webmaster_email = "Myemail@mail.com";
/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page = "feedback_form.html";
$error_page = "error_message.html";
$thankyou_page = "thank_you.html";
/*
This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.
*/
$email_address = $_REQUEST['email_address'] ;
$comments = $_REQUEST['comments'] ;
/*
The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
*/
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}
// If the user tries to access this script directly, redirect them to the feedback form,
if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
}
// If the form fields are empty, redirect to the error page.
elseif (empty($email_address) || empty($comments)) {
header( "Location: $error_page" );
}
// If email injection is detected, redirect to the error page.
elseif ( isInjected($email_address) ) {
header( "Location: $error_page" );
}
// If we passed all previous tests, send the email then redirect to the thank you page.
else {
mail( "$webmaster_email", "Feedback Form Results",
$comments, "From: $email_address" );
header( "Location: $thankyou_page" );
}
?>
但是,发生的是,当我单击第一个表单上的提交"时,最终下载了send_mail.php文件.
我怎么了正确的方法是什么?谢谢大家.
注意:我已从网站上将其下载为模板:
http://www.quackit.com/php/tutorial/php_mail_configuration.cfm [ ^ ]
But, instead, what happens is that when I click submit on the first form, I end up downloading the send_mail.php file.
What is my problem? And what is the proper approach? Thanks to all.
NOTE: I had downloaded this as a template from a website:
http://www.quackit.com/php/tutorial/php_mail_configuration.cfm[^]
推荐答案
webmaster_email = " ; /* 该位设置支持页面的URL. 如果您更改任何页面的名称,则需要在此处更改值. */
webmaster_email = "Myemail@mail.com"; /* This bit sets the URLs of the supporting pages. If you change the names of any of the pages, you will need to change the values here. */
feedback_page = " ;
feedback_page = "feedback_form.html";
error_page = "
error_page = "error_message.html";
这篇关于按钮功能正常的问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!