我正在构建一个 php 联系表单,用于检查是否填写了某些字段(没有 ajax)。表格不能 100% 工作。我会尽力解释。当我提交表单时,用户导航到http://mydomain.com/send.php 收到我的错误消息(如果有的话)。当我刷新 send.php 页面时,我收到以下错误:注意:未定义索引:/Library/WebServer/Documents/~aledvertising/send.php 中的名称
这是我的代码
html表单
<form method="post" action="send.php">
<div id="form-top">
</div>
<div id="form-left">
<label>Naam:<span class="star">*</span></label>
<input name="name" placeholder="Uw naam">
<label>Email:<span class="star">*</span></label>
<input name="email" type="email" placeholder="Uw email">
<label>Hoeveel is 2+2? (Anti-spam)<span class="star">*</span></label>
<input name="human" placeholder="Uw antwoord">
</div>
<div id="form-right">
<label>Uw bericht:<span class="star">*</span></label>
<textarea name="message" placeholder="Uw bericht"></textarea>
</div>
<input id="submit" name="submit" type="submit" value="Verzenden">
</form>
发送.PHP
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: ' . $_POST['email'];
$to = 'myemail@mail.com' . ', ';
$to .= $_POST['email'];
$subject = 'Uw vraag op www.aledvertising.be';
$human = $_POST['human'];
$body = "From: $name\n E-Mail: $email\nMessage:\n $message";
?>
<?php
if ($_POST['submit']) {
if ($name != '' && $email != '' && $message != '') {
if ($human == '4') {
if (mail ($to, $subject, $body, $from)) {
echo '<p class="green">Uw bericht is succesvol verzonden.</p>';
} else {
echo '<p>Er iets misgelopen, probeer opnieuw aub.</p>';
}
} else if ($_POST['submit'] && $human != '4') {
echo '<p>2+2 is niet gelijk aan het getal dat u hebt ingevoerd.</p>';
}
} else {
echo '<p>Alle velden met een * zijn verplicht in te vullen.</p>';
}
}
?>
有人可以帮我获得一份完整的工作表格吗?谢谢