gpt4 book ai didi

php - 自定义 php 错误信息 fadein

转载 作者:可可西里 更新时间:2023-11-01 01:05:15 24 4
gpt4 key购买 nike

我编写了以下代码作为我网站用户注册过程的一部分。显然,一旦用户填写了他们的电子邮件并点击提交,表单数据就会通过以下方式发送:

<?php

if(isset($_POST['email'])){

$email_from = $_POST['email'];

function died($error) {
echo $error;
die();
}

if(!isset($_POST['email'])) {
died($error);
}

$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {

$error_message .= ' <script type="text/javascript">
alert("The email address you entered does not appear to be valid");
window.location = "http://www.domain.com/";
</script> ' ;
}

if(strlen($error_message) > 0) {
died($error_message);
}

etc, etc, etc....

我真的很感激能得到一些帮助的是这段脚本:

$error_message .= ' <script type="text/javascript">
alert("The email address you entered does not appear to be valid");
window.location = "http://www.domain.com/";
</script> ' ;
}

如何创建一个在 html 页面上淡入(并在点击时淡出)的错误消息,而不是在重定向到 html 页面之前在空白的白色 php 页面前面发出 js 警报?

谢谢!

最佳答案

<span class="fadeInMessage" style="display:none;">"The email address you entered does not appear to be valid"</span>

这将从不可见开始。然后你会写下面的代码:

$(function(){
$('.fadeInMessage').fadeIn();
});

关于php - 自定义 php 错误信息 fadein,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12501026/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com