Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox 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.

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: 553
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: 553
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
Tags: , , , ,



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

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


Search Engine Optimization by vBSEO 3.2.0