943,857 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 845
  • PHP RSS
Jun 4th, 2008
0

Use form data in substr?

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
forwardlookguy is offline Offline
23 posts
since Jun 2008
Jun 4th, 2008
0

Re: Use form data in substr?

$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 .
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Jun 4th, 2008
0

Re: Use form data in substr?

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,
Reputation Points: 10
Solved Threads: 15
Junior Poster in Training
silviuks is offline Offline
95 posts
since Apr 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: How to return a mysql result set
Next Thread in PHP Forum Timeline: login page redirects to itself as a loop:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC