Jump to content

grabbing values from an array


bumdeal2

Recommended Posts

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.