Daney11 Posted February 8, 2008 Share Posted February 8, 2008 Hey guys, Im using if (eregi ('^[[:alpha:]\.\'\-]{2,80}$', stripslashes(trim($_POST['result_link'])))) { $result_link = escape_data($_POST['result_link']); } else { $result_link = FALSE; $errors[] = 'Please Enter A Link'; } which is working fine. BUT im not sure how to add 2 links into it. for example. if (eregi ('^[[:alpha:]\.\'\-]{2,80}$', stripslashes(trim($_POST['result_link'])), stripslashes(trim($_POST['result_link1'])), )) { $result_link = escape_data($_POST['result_link']); } else { $result_link = FALSE; $errors[] = 'Please Enter A Link'; } doesnt work. ANyone any ideas? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/90062-solved-if-and-elseif/ Share on other sites More sharing options...
aschk Posted February 8, 2008 Share Posted February 8, 2008 Check the documentation for eregi, it only takes 1 string parameter http://uk3.php.net/eregi If you want to perform this eregi comparison on more than one string, i.e. secret line and secret link1 then you need to do it for each of them. e.g. if (eregi ('^[[:alpha:]\.\'\-]{2,80}$', stripslashes(trim($_POST['result_link']))) && eregi ('^[[:alpha:]\.\'\-]{2,80}$', stripslashes(trim($_POST['result_link1'])))) { ... Quote Link to comment https://forums.phpfreaks.com/topic/90062-solved-if-and-elseif/#findComment-461759 Share on other sites More sharing options...
Daney11 Posted February 8, 2008 Author Share Posted February 8, 2008 that doesnt work Quote Link to comment https://forums.phpfreaks.com/topic/90062-solved-if-and-elseif/#findComment-461768 Share on other sites More sharing options...
aschk Posted February 8, 2008 Share Posted February 8, 2008 What Error? Maybe you should split this out into a function and use that instead... function performTest($value){ $value = stripslashes($value); $value = trim($value); if (eregi ('^[[:alpha:]\.\'\-]{2,80}$', $value)) { return true; } return false; } if(performTest($_POST['result_link']) AND performTest($_POST['result_link1'])){ $result_link = escape_data($_POST['result_link']); } else { $result_link = FALSE; $errors[] = 'Please Enter A Link'; } Quote Link to comment https://forums.phpfreaks.com/topic/90062-solved-if-and-elseif/#findComment-461771 Share on other sites More sharing options...
Daney11 Posted February 8, 2008 Author Share Posted February 8, 2008 works a treat. thanks very much Quote Link to comment https://forums.phpfreaks.com/topic/90062-solved-if-and-elseif/#findComment-461776 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.