form validation

I have a small problem. I have setup a site with php/sql.
The user enters a code, and they’re returned a random procedure code, and all this along with a timestamp is stored n the DB, and listed back.

Anyways, its all workign very nicely, but I need to setup some sort of validation for the one code that is entered.

It is something like ABC-TT-01.
The only thing that’ll change is the 2 numbers in the end. I want the script to not allow anything else. I found some scripts that did this, but I can’t find them again.

Can anyone help?

Re: form validation

ok, maybe adding a prefix to it is a more simpler option. i mean, instead of forcing the user to put in abc-tt-o1, we can just let them add 01, and attach the prefix 'abc-tt-' using php.

so my question is .. err how do i do it.. i've been googling, but can't anything decent .. any ideas?

Re: form validation

sorry, i am not a programming person but you can always ask, najim or any other elders here to help you out.

I am replying because no one replied to your thread, you can contact them through pm. they might be busy you know

Re: form validation

do you want user input for this or some random number for each entry? or a counter?

Re: form validation

All I want now is a way to add a 'prefix' to a 2 digit number the user is going to enter.

Ex.

the user enters 34, and I want a php string manipulation function (is that what they're called?) to add a ABC-TT- infront, and returning ABC-TT-34.

Originally, I wanted the user to add the whole string, but that would require input validation, and I thought, it'll be easier if I just let the script add the prefix ...

I don't mind doing some reading, but i'm not sure what to read ...

Re: form validation

well that would be simple conatenating the two strings...
see if this might help u..
The Concatenation Operator
The concatenation operator is a single dot. Treating both operands as strings, it appends the right-hand operand to the left. So

"hello"." world"
returns
"hello world"
Regardless of the data types of the operands, they are treated as strings, and the result always is a string.

Source : SAMS Teach Yourself PHP4 in 24 hrs.

Re: form validation

use Regular Expressions..

Re: form validation

Thanks for the pointers/

I'll read up on Concatenation Operator and Regular Expressions

See where this goes.

Re: form validation

http://www.phpbuilder.com/manual/ref.regex.php

here’s an article which will get you started. there are more useful articles on this website on reg-exp. They maybe a bit complex to understand in the beginning. But, once you know them well; extremely powerful for and kind of data and forms validation.

-a

Re: form validation

errr. is it possible to add a prefix to a form input? on the same page?

I can do it by using session, and assigning the form input to a $variable, on the 2nd page, but, can it be done on the same page?

Re: form validation

i'm going crazy trying to figure this out, but i can't seem ot find how to combine a user input with a $variable, wihout using session variables, and combining them on a second page ...

anyways.. i was thinking .. maybe it is possible to add a prefix once the data gets loaded into the mysql db. is that possible? I mean, the form inserts '23' into the code column, and it is automatically prefixed (ex ABC-TT-).

That would make things simple, but I've been googling for the last 30 minutes, and can't find any documentation ..