表单验证灯箱 PHP if/else 语句

发布于 2024-12-02 03:34:57 字数 1600 浏览 3 评论 0原文

嘿伙计们,我正在努力解决这个问题。

我想我了解灯箱及其工作原理。我在游戏服务器上使用过,效果很好;直到我在 php 的 if else 语句中使用它来测试表单验证。如果用户填写的表单不正确,则应该弹出失败图像的灯箱,但事实并非如此。我确实希望在这美妙的景色中有人能帮助我

<html> 
<?php
<head>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/j``avascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
 <link rel="stylesheet" type="text/css" href="css.css" />  
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
</head> 
$EmailAddres = $_POST[Email];
$FirstName = $_POST[FName];
$LastName = $_POST[LName];
$PhoneNumber = $_POST[Phone];
$AltPhoneNumber = $_POST[AltPhone];


//This is the testing and the validation testing
$flag="OK";
$msg="";
$todo="test";



if(!ereg("^[-A-Za-z]*$",$FirstName)){
     echo "Invalid first Name";
     $flag="NOTOK";
}

if(!ereg("^[-A-Za-z]*$",$LastName)){
   echo "Invalid Last Name";
   $flag="NOTOK";
}


if(!ereg("^[-A-Za-z0-9_]+[-A-Za-z0-9_.]*[@]{1}[-A-Za-z0-9_]+[-A-Za-z0-9_.]*[.]{1}[A-Za-    z]{2,5}$",$_POST[Email])){
     echo "Invalid Email Address";
     $flag="NOTOK";
}

/*This is to validate the phone number input */ 
    if(!ereg("[0-9]{10,11}", $PhoneNumber)){
         echo "Invalid phone number"; 
         $flag="NOTOK";
} 


if($flag == "NOTOK"){
    echo '<p><a href="images/fail.png" rel="lightbox" class="lightbox_trigger"></a></p>';
   // echo "something is definitely wrong here";  
}
?>
</html> 

Hey guys I am having the most hard time trying to figure this out.

I think I understand lightboxes and how they work. I used on in a play server and it worked fine; until I used it in an if else statement in php to test out form validation. If the user fills the form inproperly than this lightbox of a fail image should popup, but it doesn't. I do hope that someone in this wonderful sight could help me

<html> 
<?php
<head>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/j``avascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
 <link rel="stylesheet" type="text/css" href="css.css" />  
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
</head> 
$EmailAddres = $_POST[Email];
$FirstName = $_POST[FName];
$LastName = $_POST[LName];
$PhoneNumber = $_POST[Phone];
$AltPhoneNumber = $_POST[AltPhone];


//This is the testing and the validation testing
$flag="OK";
$msg="";
$todo="test";



if(!ereg("^[-A-Za-z]*$",$FirstName)){
     echo "Invalid first Name";
     $flag="NOTOK";
}

if(!ereg("^[-A-Za-z]*$",$LastName)){
   echo "Invalid Last Name";
   $flag="NOTOK";
}


if(!ereg("^[-A-Za-z0-9_]+[-A-Za-z0-9_.]*[@]{1}[-A-Za-z0-9_]+[-A-Za-z0-9_.]*[.]{1}[A-Za-    z]{2,5}$",$_POST[Email])){
     echo "Invalid Email Address";
     $flag="NOTOK";
}

/*This is to validate the phone number input */ 
    if(!ereg("[0-9]{10,11}", $PhoneNumber)){
         echo "Invalid phone number"; 
         $flag="NOTOK";
} 


if($flag == "NOTOK"){
    echo '<p><a href="images/fail.png" rel="lightbox" class="lightbox_trigger"></a></p>';
   // echo "something is definitely wrong here";  
}
?>
</html> 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩起发的微风 2024-12-09 03:34:57

仅使用 PHP 打印出链接引用是不够的。您需要启动 javascript。

这是解决您完全相同问题的人的一篇简短博客文章。它比较旧,但很有效。

http:// www.bram.us/2007/07/30/my-code-snippet-automatically-start-lightbox-on-page-load/

It's not enough to just print out the link reference with PHP. You need to set the javascript in motion.

Here is a short blog entry from someone who solved your exact same problem. It's older, but it works.

http://www.bram.us/2007/07/30/my-code-snippet-automatically-start-lightbox-on-page-load/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文