Go Back   CodingForums.com > :: Server side development > Perl/ CGI

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-07-2009, 12:31 AM   PM User | #1
bazz
Master Coder

 
Join Date: Apr 2003
Location: in my house
Posts: 5,211
Thanks: 39
Thanked 201 Times in 197 Posts
bazz will become famous soon enoughbazz will become famous soon enough
regex for cleaning $cgi-Vars;

Hi,
Edit:
If anyone finds my brain please return it. It has definately gone awol. fyi, my if statement used to be an unless and so the error message was saying the opposite of what it should have

I am trying to ensure that the $params{$key} value includes only numbers and the \0 separator. I can't seem to get my regex to do it. There will be an indeterminate number of values and so also, an indeterminate number of \0.

Code:
foreach my $key (sort %params ) # loop through all sent params and show the completed form with errors
  {
    if ($key =~ /set_value/  && $params{$key} =~ /[0-9]+(\0)+/ ) 
    {  # clean the params and values passed to this sub.
      
    @values = split(/\0/, $params{$key} ); 

    print qq( params{key}=$params{$key} );
  
       print qq( <p>You have entered some invalid data causing this process to be terminated</p>);
       exit;
    }
  }
The process error message always shows up. what should I be doing?

bazz
__________________
"The day you stop learning is the day you become obsolete"! - my late Dad.

Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
Useful MySQL resource
Useful MySQL link

Last edited by bazz; 06-07-2009 at 01:35 AM..
bazz is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:34 AM.


Advertisement
Log in to turn off these ads.