这是我写的一个PHP脚本,所以我可以从我的投资组合中获取信息。由于某种原因,它没有显示结束脚本回声。显示白页,没有发送电子邮件?我环顾四周,没有看到任何东西。
<?php
$name = $_POST['c_name'];
$email = $_POST['c_email'];
$ref = $_POST['c_ref'];
$message = $_POST['c_message'];
$submit = $POST['f_submit'];
$from = 'From: Portfolio';
$to = 'user@email.com';
$subject = 'Website Request';
$body = "Name: $name\n
Email: $email\n
Reference: $ref\n
Message: $message\n";
if ($_POST['f_submit']) {
if ($name != '' && $email != '') {
if (mail ($to, $subject, $body, $from)) {
echo "Thank you for your quote we will be contacting you within 24 hours!";
}else{
echo "Unfortunatley something went wrong try entering your information one more time.";
}
}
}
?>
HTML:
<form id="job_request" action="assets/php/hire_me.php" method="post">
<div class="row">
<div class="col-md-6 ">
<div class="form-group">
<input name="c_name" type="text" class="form-control" required="required" placeholder="Name">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input name="c_email" type="text" class="form-control" required="required" placeholder="Email address">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 ">
<div class="form-group">
<input name="c_subject" type="text" class="form-control" required="required" placeholder="Subject">
</div>
</div>
<div class="col-md-6 ">
<div class="form-group">
<input nae="c_ref" type="text" class="form-control" placeholder="Ref. (IF any)">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 ">
<div class="form-group">
<textarea name="c_message" id="message" required class="form-control" rows="3" placeholder="Message"></textarea>
</div>
<div class="form-group">
<button name="f_submit" type="submit" class="btn btn-primary">Submit Request</button>
答案 0 :(得分:0)
我假设你在网页上刷新时会得到一个白页?
你错过了第6行的下划线
$submit = $POST['f_submit'];
应该是
$submit = $_POST['f_submit'];
其次,该行只会在邮件出现问题时打印,而不会在名称/电子邮件为空白时打印。这似乎不是正确的行为;如果发送电子邮件的基本要求不起作用,对吧?所以也许更像是这样的东西:
if ($_POST['f_submit']) {
if ($name != '' && $email != '') {
if (mail ($to, $subject, $body, $from)) {
echo "Thank you for your quote we will be contacting you within 24 hours!";
else {
//DECIDE IF YOU WANT TO DO ANYTHING HERE
}
}
else {
echo "Unfortunatley something went wrong try entering your information one more time.";
}
}