PDA

Click to See Complete Forum and Search --> : Form Submit Q


lintz
Jul 31st, 2006, 10:19 PM
I have a form where the user can input a number of share codes (seperated by ,) into a textarea. When the user then clicks the submit button I want to be able to check the share codes entered against a "master" list of share codes I have in an array (using in_array()). If any share codes entered by the user aren't in the master array then I want to display a message of all share codes that were not found.

Can this be done using PHP or would I have to try and use Javascript?

visualAd
Jul 31st, 2006, 11:11 PM
You can use AJAX, which is a mixture of Javascript and PHP. Have a look at the article in my signature which has an example.

R.a.B.B.i.T
Aug 1st, 2006, 09:03 AM
He said after the user clicks submit.

What I would do is explode the string of the codes (with "," as the delimiter), and then foreach() through the master list, checking input codes with in_array() (I'd also clean them with strtolower()/strtoupper() and trim()). If the in_array() result is false, add the inputted item to a third array, and then handle your output with that.

lintz
Aug 2nd, 2006, 01:08 AM
Thanks Rabbit, that is what I ended up doing :thumb: