如果响应有效,则显示窗口警报

Show window.alert if response is valid

本文关键字:窗口 显示 响应 有效 如果      更新时间:2023-09-26

嗯...我试过这个:

if ($resp->is_valid) {
    @mail($email_to, $email_subject, $email_message, $headers);
    print "<script language="javascript">
    window.alert("'Thank you for submitting the track. We will be in touch with you very soon. Click 'Ok' to redirect you to the Homepage.'")
    window.location.href='http://www.xmasterofficial.tk/'
    </script>";
} else {
    echo "Sorry cannot send email as you've failed to provide correct captcha! Try again...";
}

我不知道问题出在哪里。如果$resp有效,它应该创建一个 window.alert,如果无效,则应发布消息。window.alert 未显示。

代码在

打印语句中使用引号时存在一些问题。使用echo而不是print处理多个字符串时,您需要单独处理引号才能执行此操作,这必须帮助您使用警报选项。

if ($resp->is_valid) {
@mail($email_to, $email_subject, $email_message, $headers);
echo "<script language='javascript'>
window.alert('Thank you for submitting the track. We will be in touch with you very soon. Click Ok to redirect you to the Homepage.')
window.location.href='http://www.xmasterofficial.tk/'
</script>";
} else {
echo "Sorry cannot send email as you have failed to provide correct captcha! Try again...";
}
if ($resp->is_valid) {
@mail($email_to, $email_subject, $email_message, $headers);
echo "<script type='text/javascript'>
alert('Thank you for submitting the track. We will be in touch with you very soon. Click Ok to redirect you to the Homepage.');
window.location.href='http://www.xmasterofficial.tk/';
</script>";
} else {
echo "Sorry cannot send email as you have failed to provide correct captcha! Try again...";
}