-5
好的,我遵循教程,只是改變了一些變量並創建了它們。我在下面有一個HTML和PHP代碼,PHP有什麼問題導致它不工作?有任何想法嗎。PHP - FORM TO MAIL NOT WORKING
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = " MY EMAIL ";
$email_subject = "FORM SUBMISSION";
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['address']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['message'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name']; // required
$address = $_POST['address']; // required
$email = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$message = $_POST['message']; // required
$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 .= "Name: ".clean_string($name)."\n";
$email_message .= "Address: ".clean_string($address)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Message: ".clean_string($message)."\n";
// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message);
?>
<?php
header('Location: MY LINK IS HERE BUT NOT WORKING');
?>
<?php
}
?>
形式
<div class="row contact-form">
<div class="container">
<h3>Get In Touch</h3>
<div class="col-sm-6">
<div class="row">
<form name="email" action="php/mail.php" method="POST">
<div class="col-sm-6">
<p class="input-label">Name <span class="star-red">*</span>
</p>
<input type="text" name="name" id="name" class="form-input-wide" required>
</div>
<div class="col-sm-6">
<p class="input-label">Address</p>
<input type="text" name="address" id="address" class="form-input-wide">
</div>
</div>
<div class="row">
<form name="send-mail" action="php/mail.php" method="POST">
<div class="col-sm-6">
<p class="input-label">Telephone <span class="star-red">*</span>
</p>
<input type="tel" name="telephone" id="telephone" class="form-input-wide" required>
</div>
<div class="col-sm-6">
<p class="input-label">Email <span class="star-red">*</span>
</p>
<input type="email" name="email" id="email" class="form-input-wide" required>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<p class="input-label">Message <span class="star-red">*</span>
</p>
<textarea name="message" id="message" style="width:100% !important;" rows="6" required></textarea>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<input type="submit" class="submit-button">
</div>
</div>
<div class="row">
<div class="col-sm-6">
 
</div>
</div>
</form>
</div>
</div>
</div>
</div>
如果有什麼事情,我需要改變嗎?我認爲錯誤信息可能會破壞PHP。
你得到的錯誤是什麼? – Gunaseelan
給錯誤 –
更改'死($ error_message);'死'($ error_message);'它會告訴你什麼是錯的。 –