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.
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?
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 ...
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.
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.
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 ..