iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-20-2003, 04:18 PM
WebProWorld New Member
 
Join Date: Nov 2003
Posts: 5
Lionelandre RepRank 0
Default PHP Generic check of URL values

Hi,

I am looking to write a PHP function that would read the URL and verify that none of the values are blank. Now, granted, I could do this manually for each occurence, but I can have my usrl like this:

http://www.somesite.com/index.php3?var1=val1

or like so:

http://www.somesite.com/index.php3?R...t=Submit+Query

I'm sure a genius out there has written a function out there that I can reuse, right ? :)

Thanks a lot, guys.

Lionel
Reply With Quote
  #2 (permalink)  
Old 11-20-2003, 04:53 PM
redcircle's Avatar
WebProWorld Veteran
 
Join Date: Aug 2003
Location: Grand Rapids, MI USA
Posts: 425
redcircle RepRank 0
Default

Code:
function check_blank($get)
{

  if(is_array($get))
     {
       foreach($get as $key=>$value)
        {
          if(!isset($value))
             {
                $error.=$key .' has no value
';
             }
        }
      }
   if($error)
     {
       $error =  'ERROR: an error has occured
'.$error;
       return $error;
      }
}
useage would be
echo get_blank($_GET);

or an array that you would want to check. Only thing is this will fail if the value they entered is 0
Reply With Quote
  #3 (permalink)  
Old 11-20-2003, 04:58 PM
WebProWorld New Member
 
Join Date: Nov 2003
Posts: 5
Lionelandre RepRank 0
Default

Very cool.

I figure I could use

if ($value != ""){
.....
}

in lieu of

if(!isset($value)) {
...
}

As you can tell, I'm just getting started and I'm learning as I'm doing!

Thanksmuch!

:L
Reply With Quote
  #4 (permalink)  
Old 11-20-2003, 08:25 PM
redcircle's Avatar
WebProWorld Veteran
 
Join Date: Aug 2003
Location: Grand Rapids, MI USA
Posts: 425
redcircle RepRank 0
Default

no problem.. glad I could help
Reply With Quote
  #5 (permalink)  
Old 12-21-2003, 01:50 PM
WebProWorld New Member
 
Join Date: Dec 2003
Posts: 5
trinski RepRank 0
Default cool :)

i'd do this:

function blankChecker() {

if($_POST['name'] == '' ||
$_POST['address'] == '') {

return 'Error: Do not leave fields blank.'
}
}

Your suggestion is way cool. More efficient, I must say. :)
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 08:05 PM.



Search Engine Optimization by vBSEO 3.3.0