我只是一件快事。我启动时,我的页面出现了HTML 500错误,但我根本无法看到我的代码有什么问题。我正在尝试在我的网页上创建一个联系表单,只需获取详细信息并在用户单击表单时通过电子邮件发送给我。该页面将不会加载此代码。
<form method="post">
<input type="text" name="contact-name" placeholder="Name." required>
<input type="email" name="contact-email" placeholder="Email." required>
<input type="text" name="contact-subject" placeholder="Subject." required>
<br><br>
<textarea name="contact-content"></textarea>
<div id="contact-btn-wrap">
<input type="submit" name="contact-submit" id="login-btn-signup" value="SEND EMAIL">
</div>
</form>
<br><br><br><br>
<div class="contact-me">danashton89@gmail.com | 07714709250</div>
</div>
</div>
<div class="contact-img">
<img src="/uploads/Portfolio/Level_Design/Unreal_Engine/Ice_Cove/icecastle_3.png">
</div>
<?php
$contact-name = "";
$contact-email = "";
$contact-subject = "";
$contact-content = "";
if (isset($_POST['contact-submit']))
{
$contact-name = mysqli_real_escape_string($con, $_POST['contact-name']);
$contact-email = mysqli_real_escape_string($con, $_POST['contact-email']);
$contact-subject = mysqli_real_escape_string($con, $_POST['contact-subject']);
$contact-content = mysqli_real_escape_string($con, $_POST['contact-content']);
$to = "danashton89@gmail.com";
$subject = $contact-subject;
$txt = $contact-content;
$headers = "From: " . $contact-name . "<br>" . $contact-email . "\r\n";
$headers.= "MIME-version: 1.0\n";
$headers.= "Content-type: text/html; charset= iso-8859-1\n";
mail($to,$subject,$txt,$headers);
}
?>
答案 0 :(得分:3)
我认为您不能在变量名称中使用破折号($ contact-name ...)
答案 1 :(得分:3)
首先,你不能用' - '
在php中声明变量变量名遵循与PHP中其他标签相同的规则。有效的变量名称以字母或下划线开头,后跟任意数量的字母,数字或下划线。作为正则表达式,它将表达为:'[a-zA-Z_ \ x7f- \ xff] [a-zA-Z0-9_ \ x7f- \ xff] *'
其次,您的连接var已定义?
最后,你能提供错误字符串吗?