好的,最初的建议似乎有效。没有像以前那样的错误代码。但现在它告诉我它没有结束。我尝试了多种语法,但似乎没有任何效果。并且IF将它带走......甚至删除<? end if ?>
或诸如此类的东西。有什么想法吗?
<?php
$correct = true;
if ($_GET["firstname"] == "")
$correct = false;
if (preg_match("/^.+@\w+\.\w{2,4}$/", $_GET["email"]))
$correct = false;
$to = "sample@domain.com";
$subject = "Application request";
$message = "A new request has come in!\n\n";
$message .= $_GET["firstname"];
$message .= $_GET["lastname"];"\n";
$message .= $_GET["email"];"\n";
$message .= $_GET["phone"];"\n";
$message .= $_GET["dropdown"];"\n";
$message .= $_GET["address"];"\n";
$message .= $_GET["dropdown2"];"\n";
$message .= $_GET["textarea"];"\n";
?>
<html>
<head>
<title>something funky
</title>
</head>
<body>
<?php if ($correct): ?>
Thank you for applying. We will get back to you shortly.<br>
<?php else: ?>
Please complete the form.
<?php end ?>
</body>
</html>
答案 0 :(得分:4)
更改
<?php end ?>
通过
<?php endif; ?>
答案 1 :(得分:2)
您的代码:
$message .= $_GET["lastname"];"\n";
您必须用点字符替换半冒号:
$message .= $_GET["lastname"] . "\n";
答案 2 :(得分:0)
你错过了endif
。试试这个,
<?php if ($correct): ?>
Thank you for applying. We will get back to you shortly.<br>
<?php else: ?>
Please complete the form.
<?php endif; ?>
答案 3 :(得分:0)
更改
<?php if ($correct): ?>
Thank you for applying. We will get back to you shortly.<br>
<?php else: ?>
Please complete the form.
<?php end ?>
要
if($correct){
// thank you for ...
}
else{
// please complete
}
答案 4 :(得分:0)
所以你可以使用它:
<body>
<?php if ($correct) { ?>
Thank you for applying. We will get back to you shortly.<br>
<?php } else { ?>
Please complete the form.
<?php } ?>
</body>
它不整洁但工作正常
你也可以写它
<body>
<?php
if ($correct) echo "Thank you for applying. We will get back to you shortly.<br>";
else echo "Please complete the form.";
?>
</body>