Javascript 使用弹出窗口获取有关错误的信息
我有这样的PHP表单:Javascript 使用弹出窗口获取有关错误的信息,javascript,php,forms,popup,Javascript,Php,Forms,Popup,我有这样的PHP表单: <?php if (isset($_POST["submit"])) { $name = (string) $_POST['name']; $email = (string) $_POST['email']; $message = (string) $_POST['message']; $number = (string) $_POST['number']; $tel
<?php
if (isset($_POST["submit"])) {
$name = (string) $_POST['name'];
$email = (string) $_POST['email'];
$message = (string) $_POST['message'];
$number = (string) $_POST['number'];
$tel = (string) $_POST['tel'];
$model = implode(',', $_POST['model_list']);
$captcha = (string) $_POST['captcha'];
$from = 'abc@domain.tld';
$to = 'cba@domain.tld';
$subject = 'Form service';
$body = "$name \n $email \n $tel \n $number \n $model \n $message \n";
try {
if (!$name) {
throw new Exception('Error 1');
}
if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new Exception('Error 2');
}
if($captcha > 10) {
} elseif ($captcha < 1) {
throw new Exception('Error 3');
}
if(!$number) {
throw new Exception('Error 4');
}
if(!$number) {
throw new Exception('Error 5');
}
if (!$message) {
throw new Exception('Error 6');
}
if(!empty($_POST['model_list'])) {
foreach($_POST['model_list'] as $model) {
}
} else {
throw new Exception('Error 7');
}
if (mail ($to, $subject, $body, $from, $captcha, $model)) {
$result = "Your message has been sent!";
} else {
throw new Exception('Your message has not been sent! Try again.');
}
} catch(Exception $e){
$result = "<center><div style='color:white;font-size:25px;font-weight:700;'>" . $e->getMessage() . "</div></center>";
}
echo $result;
}
查看语法突出显示;您有错误,这是正在抛出if off的部分$body=[这是通过电子邮件发送的内容]
抛出新异常('Error 4)
现在正在抛出它抛出新异常('Error 4')
-请,如果您使用的是正确的代码,您应该发布它。其他人可能会认为你的代码因此而失败。非常感谢,我不得不编辑这些地方,因为这些错误是用不同的语言编写的,我不会全部编辑。不客气。是的,你需要使用JS来弹出一个窗口。PHP不能处理这类事情,所以这是我写过的一个问题。我从来没有学过JS,从中我什么都不懂,我也不知道有谁知道。