嘿那里:) 第一次使用这个网站。
我是 php、DW 的新手,我在 Imac 上工作。我已经尝试了两天来获得一份简洁的表格。我希望它在我们收到它时向我的 gmail 或我们公司的电子邮件发送一封电子邮件。
我已经将它上传到 FTP 服务器,但是当我输入数据时,我得到了这个:
服务器错误 405 - 不允许用于访问此页面的 HTTP 谓词。无法显示您要查找的页面,因为尝试访问的方法(HTTP 动词)无效。
我真的希望你们能帮助我,用一些容易理解的术语:P
我的 HTML:
<h2>Kontakt os</h2>
<form class="form" name="contactform" method="post" action="php/send_form_email.php">
<p class="name">
<input type="text" name="first_name" maxlength="50" size="30" placeholder="Fornavn:">
<label for="first_name"></label>
</p>
<div class="seperator1"></div>
<p class="lastname">
<input type="text" name="last_name" maxlength="50" size="30" placeholder="Efternavn:">
<label for="last_name"></label>
</p>
<div class="seperator1"></div>
<p class="email">
<input type="text" name="email" maxlength="80" size="30" placeholder="Email:">
<label for="email"></label>
</p>
<div class="seperator1"></div>
<p class="phone">
<input type="text" name="telephone" maxlength="30" size="30" placeholder="Tlf:">
<label for="telephone"></label>
</p>
<div class="seperator1"></div>
<p class="text">
<textarea name="text" placeholder="Skriv til os her" /></textarea>
<label for="text"></label>
</p>
<p class="submit">
<input type="submit" value="Submit">
</p>
</form>
我的PHP代码:
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "mikkelmadsen.info@gmail.com";
$email_subject = "Mysole";
function died($error) {
// your error code can go here
echo "Undskyld, men det ser ud til der er sket en fejl.";
echo "Fejl står nedeunder.<br /><br />";
echo $error."<br /><br />";
echo "Gå venligst tilbage for at rette fejlen.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['text'])) {
died('Undskyld, men det ser ud til der er sket en fejl.');
}
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['text']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'Forkert email adresse.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'Forkert fornavn.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'Forkert efternavn.<br />';
}
if(strlen($text) < 2) {
$error_message .= 'Den tekst du har skrevet er ikke gyldig.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Text: ".clean_string($text)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Klik her <a href="../kontakt.html"></a> at komme tilbage til forsiden.
<?php
}
?>