Use form data in substr?

Thread Solved

Join Date: Jun 2008
Posts: 23
Reputation: forwardlookguy is an unknown quantity at this point 
Solved Threads: 0
forwardlookguy forwardlookguy is offline Offline
Newbie Poster

Use form data in substr?

 
0
  #1
Jun 4th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Use form data in substr?

 
0
  #2
Jun 4th, 2008
$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 .
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 66
Reputation: silviuks is an unknown quantity at this point 
Solved Threads: 11
silviuks silviuks is offline Offline
Junior Poster in Training

Re: Use form data in substr?

 
0
  #3
Jun 4th, 2008
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,
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC