bumdeal2 Posted October 3, 2011 Share Posted October 3, 2011 Hey guys, I am having issue with understanding/implementing an array. Currently my code does the following it displays an array of values to the user as a note and allows the user to enter in values if they wish. This is done through using a select a statement which displays those values through a while loop.I then use a line like so:-<textarea name=Details[detailsno] value="'.$Text.'">"'.$Text.'"... which passes the input from the user into an array. Underneath this I have a checkbox that allows the user to select particular notes to update.<input type=checkbox name=update[] value=Update>. This passes over the values correctly. The problem im currently having is grabbing the values that the user has entered for those particular detailsno so that I can implement an insert statement. i was wondering if you knew how to do this? Thank you for taking your time to even read this or even help its much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/248359-grabbing-values-from-an-array/ Share on other sites More sharing options...
gizmola Posted October 3, 2011 Share Posted October 3, 2011 The script that is the target of the post will have any posted values in the $_POST superglobal array. All you need do is go through those values using a foreach() loop: foreach($_POST as $key => $value) { echo "$key: $value "; } You didn't specify which database you are using, but you will at very least need to do some input validation. At minimum you need to escape characters relevant to any strings you are inserting into char types, and you might also want to run htmlentities or strip_tags on it, so that malicious html/javascript that could cause xss problems is handled. From there it's simply a matter of getting the input you require and creating an insert statement for the database you're using. Without more details all we can offer is generalized help like this. Quote Link to comment https://forums.phpfreaks.com/topic/248359-grabbing-values-from-an-array/#findComment-1275388 Share on other sites More sharing options...
bumdeal2 Posted October 3, 2011 Author Share Posted October 3, 2011 Thats perfect, exactly what I was looking for and using an MySQL db dont worry im using a varcleaner class to strip all the character that could cause damage to the db and to prevent sql injection, cross scripting and all them issues that arise from Hackers. Your help is more than appreciated. :-) Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/248359-grabbing-values-from-an-array/#findComment-1275400 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.