View Single Post
  #2 (permalink)  
Old December 13th, 2004, 07:14 AM
colin.horne colin.horne is offline
Authorized User
 
Join Date: Dec 2004
Location: , , United Kingdom.
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to colin.horne
Default

Just a quick security pointer:

Doing this will allow ANYONE with access to that file to create variables within your PHP script, so if (for example), you have a variable - $is_logged_in - then someone can do this:

Name = Smeghead
Age = 20
Location = Boeblingen, Germany
is_logged_in = 1

You might want to do something like this:

Code:
$allowed_variables = array(
  "name",
  "age",
  "location"
);
Even if only certain people are allowed to access the file, doing that will also reduce the chances of someone breaking the script with a typo.

Anyway, the answer to your question is: use regular expressions.

Something like this ought to do:
/([^=]+)=(.+)/

Look up for regular expressions in the php manual, and the function needed is: php.net/preg_match.

If you still need a hand, shout :-)

Cheers

--
Please contact me at:
Colin (dot) Horne (at) gmail (dot) com
Reply With Quote