Grodo Posted May 9, 2008 Share Posted May 9, 2008 Hi, Ok I have a fuction it works great however its really slow and lags the page. I was wondering what i could do to speed it up a bit. I was thinking to make a for loop to check variables such as this: $sizeBlah=sizeof($message); $listVars[fname] = "fname"; $listVars[lname] = "lname"; $listMessage[0] = "Please insert you first name"; $listMessage[1] = "Please insert you last name"; for ($blah=0;$blah <=$sizeBlah;$blah++) { global $HTTP_POST_VARS, $error, $print_again, $message; // Validate first name $error[$listVars[$blah]] = false; if($_POST[$listVars[$blah]]=="") { $error[$listVars[$blah]] = true; $print_again = true; $message[]=$listMessage[$blah]; } } However I cant get this to work function check_form() { global $HTTP_POST_VARS, $error, $print_again, $message; // Validate first name $error['fname'] = false; if($_POST["fname"]=="") { $error['fname'] = true; $print_again = true; $message[]="Please insert you first name<br>"; } // Validate last name $error['lname'] = false; if($_POST["lname"]=="") { $error['lname'] = true; $print_again = true; $message[]="Please insert you last name<br>"; } // Validate Address $error['address1'] = false; if($_POST["address1"]=="") { $error['address1'] = true; $print_again = true; $message[]="Please enter a valid address<br>"; } // Validate City $error['city'] = false; if($_POST["city"]=="") { $error['city'] = true; $print_again = true; $message[]="Please enter a valid city<br>"; } // Validate State $error['state'] = false; if($_POST["state"]=="") { $error['state'] = true; $print_again = true; $message[]="Please enter a valid State or Territory<br>"; } // Validate Country $error['country'] = false; if($_POST["country"]=="") { $error['country'] = true; $print_again = true; $message[]="Please enter a valid country<br>"; } // Validate Postal code $error['zip'] = false; if($_POST["zip"]=="") { $error['zip'] = true; $print_again = true; $message[]="Please enter a valid zip<br>"; } } Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted May 9, 2008 Share Posted May 9, 2008 Your function should not be making anything run slow - there's nothing in there which could cause any slow down. If your script is running slow then either a.)you have something else in your script or b.) your host is rubbish. Quote Link to comment Share on other sites More sharing options...
Grodo Posted May 9, 2008 Author Share Posted May 9, 2008 Seems like my host is rubish I would love to see that loop work. I just cant get it Quote Link to comment Share on other sites More sharing options...
radar Posted May 9, 2008 Share Posted May 9, 2008 I run similar scripts on my host all the time, and they run very very quick... so its almost definately your host... Only time I ever have issues with mine is if the server has a process running thats causing an unusually high server load... So my bet: your host is garbage and you should consider switching... I can hook ya up with mine if ya want -- they're pretty cheap and freaking awesome. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.