【发布时间】:2015-06-29 14:33:15
【问题描述】:
在我的网站上,我使用表单让用户直接通过网站发送查询。为此,我使用此 PHP 代码进行处理,命名为“sendform.php”:
<?php
$body = 'Online-Anfrage';
$body .= '\r\n NAME:';
$body .= $_POST["input_name"];
$body .= '\r\n EMAIL:';
$body .= $_POST["input_email"];
$body .= '\r\n TELEFON:';
$body .= $_POST["input_telefon"];
$body .= '\r\n FAHRZEUG:';
$body .= $_POST["input_fahrzeug"];
$body .= '\r\n ERSTZULASSUNG:';
$body .= $_POST["input_erstzulassung"];
$body .= '\r\n KILOMETERSTAND:';
$body .= $_POST["input_kilometerstand"];
$body .= '\r\n PREISVORSTELLUNG:';
$body .= $_POST["input_preisvorstellung"];
$to = "my@mail.de";
$headers = 'From: info@mmymail.de' . "\r\n" .
'Reply-To: ' . $_POST["input_email"] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$subject = "Online-Anfrage";
if (mail($to, $subject, $body, $headers))
{
echo("<p>Wir haben Ihre Anfrage erhalten. Vielen Dank für Ihr vertrauen! </p>");
}
else
{
echo("<p>Interner Serverfehler. Bitte rufen Sie uns für eine Anfrage direkt an:</p>");
}
?>
但是当我尝试将 action="sendform.php" 与 index.html 一起使用时,我收到服务器错误 503。我使用的表单代码是这个:
<form class="form-horizontal" method="post" action="sendform.php">
<fieldset>
<!-- Form Name -->
<legend>Kostenlose und unverbindliche Verkaufsanfrage</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="input_name">Name</label>
<div class="col-md-6">
<input id="input_name" name="input_name" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="input_email">E-Mail Adresse</label>
<div class="col-md-6">
<input id="input_email" name="input_email" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="input_telefon">Telefonnummer</label>
<div class="col-md-6">
<input id="input_telefon" name="input_telefon" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="input_fahrzeug">Fahrzeugmodell</label>
<div class="col-md-6">
<input id="input_fahrzeug" name="input_fahrzeug" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="input_erstzulassung">Erstzulassung</label>
<div class="col-md-6">
<input id="input_erstzulassung" name="input_erstzulassung" type="text" placeholder="" class="form-control input-md" required="">
<span class="help-block">Bitte Monat und Jahr angeben.</span>
</div>
</div>
<!-- Appended Input-->
<div class="form-group">
<label class="col-md-4 control-label" for="input_kilometerstand">Kilometerstand</label>
<div class="col-md-6">
<div class="input-group">
<input id="input_kilometerstand" name="input_kilometerstand" class="form-control" placeholder="" type="text" required="">
<span class="input-group-addon">km</span>
</div>
</div>
</div>
<!-- Appended Input-->
<div class="form-group">
<label class="col-md-4 control-label" for="input_preisvorstellung">Preisvorstellung</label>
<div class="col-md-6">
<div class="input-group">
<input id="input_preisvorstellung" name="input_preisvorstellung" class="form-control" placeholder="" type="text" required="">
<span class="input-group-addon">€</span>
</div>
</div>
</div>
<button type="submit" class="btn btn-success col-md-12">Anfrage absenden!</button>
</fieldset>
</form>
我完全不知道如何解决这个问题,因为我在命名中找不到任何错误,所以肯定是有其他原因导致了这个错误。
服务器日志没有说“解析错误”之类的东西,当变量有问题时你会得到什么..
编辑:我确实收到了电子邮件,但它们只填充了静态文本,我收到的邮件中不存在变量
你能帮我解决这个问题吗?谢谢!
【问题讨论】:
-
能否提供任何 Apache 错误日志信息?
-
由于网站在共享的虚拟主机上运行,我无法访问日志文件:-/ 我只能访问错误日志,这些都是空的..
-
您之前是否使用此主机成功发送过 PHP 电子邮件?
-
是的,实际上编辑了我的帖子:编辑:我确实收到了电子邮件,但它们只填充了静态文本,我收到的邮件中不存在变量