merylvingien Posted October 14, 2009 Share Posted October 14, 2009 Hi fellas, need a little help here. I have a page that has hidden values in a form. example <input name='signupID' type='hidden' value='1' /> <input name='signupID' type='hidden' value='2' /> <input name='signupID' type='hidden' value='3' /> <input name='signupID' type='hidden' value='4' /> also within this form, the user enters details, name, phone number etc. On the next page i need these hidden values to compare to the ID in the database so i can update the rows based on this hidden value. I have obviously taken a wrong route here becuase i am getting warning after warning. The code i have tried is this: if(isset($_POST['signupID'])) { foreach($_POST['signupID'] as $item) { echo "<input name='signupID' type='hidden' value='". $item . "' />"; but i get this: Warning: Invalid argument supplied for foreach() in C:\www\wasp-control.co.uk\ on line 79 The idea is that once the user has filled in the form, hits submit, next page compares the database to these hidden values "1,2,3,4" and then updates the database where the ID in the database is "1,2,3,4" Any help here would be great Link to comment https://forums.phpfreaks.com/topic/177652-solved-a-little-help-needed-passing-hidden-values-to-next-page/ Share on other sites More sharing options...
smerny Posted October 14, 2009 Share Posted October 14, 2009 you can't have more than one input with the same name... it is probably only set as "4" Link to comment https://forums.phpfreaks.com/topic/177652-solved-a-little-help-needed-passing-hidden-values-to-next-page/#findComment-936716 Share on other sites More sharing options...
merylvingien Posted October 14, 2009 Author Share Posted October 14, 2009 Thanks for the reply smerny! Hmmm on a previous page i have multiple checkboxes all with the same name = "selected" and use this code: if(isset($_POST['selected'])) { foreach($_POST['selected'] as $item) { $sql = "SELECT * FROM Postcode WHERE postcodeID=$item"; mysql_query($sql) or trigger_error("SQL: $sql, ERROR: " . mysql_error(), E_USER_ERROR); $result = mysql_query($sql); some echo statments This works fine! Anyway, so i have to name the hidden fields individually? the trouble is that the amount of fields varies depending on what the user selected... Link to comment https://forums.phpfreaks.com/topic/177652-solved-a-little-help-needed-passing-hidden-values-to-next-page/#findComment-936743 Share on other sites More sharing options...
merylvingien Posted October 14, 2009 Author Share Posted October 14, 2009 Solved it myself. <input name='signupID[]' type='hidden' value='value' /> Link to comment https://forums.phpfreaks.com/topic/177652-solved-a-little-help-needed-passing-hidden-values-to-next-page/#findComment-936761 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.