开发者

form validation lightbox php if/else statement

开发者 https://www.devze.com 2023-04-01 08:10 出处:网络
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 state

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"&g开发者_JS百科t;</a></p>';
   // echo "something is definitely wrong here";  
}
?>
</html> 


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号