-1
我正在爲我的網頁編寫聯繫表格,但有些東西不起作用,我無法找到問題所在。當我按提交按鈕它剛剛重新加載網頁。如果有人不介意檢查我的代碼,我將不勝感激。「給我發電子郵件」聯繫表格不起作用
<?php
if(isset($_POST['submit'])){
$to = "[email protected]"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$name = $_POST['name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to, $subject, $message, $headers);
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
<section id="contact" class="parallax-section">
<div class="overlay"></div>
<div class="container">
<div class="row">
<div class="col-md-offset-2 col-md-8 col-sm-offset-1 col-sm-10">
<div class="wow fadeInUp section-title" data-wow-delay="0.3s">
<h2>Susisiekite su mumis</h2>
<h4>mes visada pasiruoše atsakyti į jums rūpimus klausimus</h4>
</div>
<div class="contact-form wow fadeInUp" data-wow-delay="0.7s">
<form id="contact-form" method="POST" action="#">
<input name="name" type="text" class="form-control" placeholder="Vardas, Pavardė" required>
<input name="email" type="email" class="form-control" placeholder="Elektroninis paštas" required>
<textarea name="message" class="form-control" placeholder="Jūsų žinutė" rows="5" cols="30" required></textarea>
<input type="submit" class="form-control submit" name="submit" value="SIŲSTI">
</form>
</div>
</div>
</div>
</div>
</section>
是您的網絡服務器配置爲使用'郵件()'? Afaik沒有開箱即可使用。 – Sirko
不清楚的問題,你能證明這是小提琴嗎? – Sushan
不太清楚,但請使用'error_reporting(E_ALL); ini_set('display_errors',1);'在你的頁面頂部,讓我們知道如果PHP返回任何錯誤 – OldPadawan