Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/90062-solved-if-and-elseif/
Share on other sites

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'])))) { ...

Link to comment
https://forums.phpfreaks.com/topic/90062-solved-if-and-elseif/#findComment-461759
Share on other sites

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';
}

Link to comment
https://forums.phpfreaks.com/topic/90062-solved-if-and-elseif/#findComment-461771
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.