-4

好的,最初的建议似乎有效。他们没有像以前那样的错误代码。但现在它告诉我它的结局并不好。我尝试了多种语法,但似乎没有任何效果。和一个 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>
4

5 回答 5

4

改变

<?php end ?>

经过

<?php endif; ?>
于 2013-04-05T17:37:42.343 回答
2

你的代码:

$message .= $_GET["lastname"];"\n";

您必须用点字符替换分号:

$message .= $_GET["lastname"] . "\n";
于 2013-04-05T17:38:27.977 回答
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; ?>
于 2013-04-05T17:37:35.103 回答
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
}
于 2013-04-05T17:37:35.893 回答
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>
于 2013-04-05T17:48:49.533 回答