954,153 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Use form data in substr?

Hello again, I previously asked a question about how to seperate text in a form. I understand how to do that now (thanks KKeith29), but my question now is this: How do I use the data entered in the form for the variable I want to perform the substr on? I've tried some different things and can't come up with anything. Once again, I'm sure it's simple but I just don't have the experience yet.

Just to clarify if anyone is lost: User inputs 4D27H2H111111 into form field. The data is submitted. I want that submitted info to be the variable upon which I use substr to seperate it into different pieces so I can then run it through the database.

Thanks again everyone,
Arthur Ash III

forwardlookguy
Newbie Poster
23 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

$variable = $_POST['form_variable_name'];
More about it here. http://w3schools.com/php/php_post.asp
You should sanitize user's input by using mysql_real_escape_string or addslashes .

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

Hello,

Maybe i didn't understand very good your problem, but i think that the first think you should do is to force users to input text following a pattern defined by you (or at least to explain how to enter the text). to be clear, for example your provided text 4D27H2H111111. will you always have 6 digits at the end of the string? then ... first 7 characters will be treated as a whole string or you want to perform some other action about this too. i think the easiest way, is to use "-" (for example, or blank space) and use explode (or split ) to have access to your desired info.

All the best,

silviuks
Junior Poster in Training
96 posts since Apr 2006
Reputation Points: 10
Solved Threads: 15
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You