Hi,
I'm currently creating my own forum "from skratch" (reason: I want features that other free forum solutions can't offer me, and don't need all of their features).
I'm now working on the "generate new password" part and I need a little help to use regular expressions to check that the validation code is in the correct format (in order to protect the forum from SQL injections).
The validationcode consists of 16 characters - (lower caps) letters and numbers. For example "d7c2xqz5tw1bj00v" or "4m3sh0bqkr1285gt"
In order to do this, I'm using:
$code = $_GET['code'];
if (!preg_match("/^[a-z0-9]{16}$/",$code)) die ("Invalid validationcode");
It seems to be working for validationcodes consisting of BOTH letters and numbers, however, I believe that the function generating the code (http://www.laughing-buddha.net/jon/php/password/) will sooner or later generate a code with only letters (as it contains 20 of them, each of which it will only use once in a code). Therefore, I also want the regular expression to accept a validation code consisting of only lower caps letters.
Your help is much appreciated. Best regards,
escanive
[SOLVED] need help with a regular expression
Moderator: General Moderators
[SOLVED] need help with a regular expression
Last edited by escanive on Mon Sep 22, 2008 8:18 am, edited 1 time in total.
Re: need help with a regular expression
Thar regex already accepts the following:
1a1a1a1a1a1a1a1a
1111111111111111
aaaaaaaaaaaaaaaa
(where 1 is any number, and a is any lowercase letter).
I can see any reason you would have any problems.
1a1a1a1a1a1a1a1a
1111111111111111
aaaaaaaaaaaaaaaa
(where 1 is any number, and a is any lowercase letter).
I can see any reason you would have any problems.
Re: need help with a regular expression
My bad ^^; - must have done something wrong while testing. Thanks.Stryks wrote:Thar regex already accepts the following:
1a1a1a1a1a1a1a1a
1111111111111111
aaaaaaaaaaaaaaaa
(where 1 is any number, and a is any lowercase letter).
I can see any reason you would have any problems.