kev wood Posted October 22, 2008 Share Posted October 22, 2008 hello i am trying to post data from one php page to another using hidden form elements. but saddly with no joy. i have already used this technique in other parts of the site but the form i am trying to send the data with is generated by php and it is not working. the variables that i am trying to post are posrted to this page with hidden form elements than used and i now trying to to post them on again for one final time. here is the code i am trying to post the data with $sql = ("SELECT * FROM $table WHERE id = $id"); $result = mysql_query($sql); $row = mysql_fetch_array($result) or die(mysql_error()); echo "<form action=\"update.php\" method=\"post\">"; echo "Date: <input type=\"text\" name=\"date\" value=\"{$row['date']}\" /><br /><br>"; echo "Title: <input type=\"text\" name=\"title\" value=\"{$row['title']}\" /><br /><br />"; echo "<input type=\"hidden\" name=\"dropdown2\" value=\"{$db['dropdown2']}\" /><br /><br />"; echo "<input type=\"hidden\" name=\"radio2\" value=\"{$table['radio2']}\" /><br /><br />"; echo "<input type=\"hidden\" name=\"id\" value=\"{$id['id']}\" /><br /><br />"; echo "Article:<br /><textarea cols=\"50\" rows=\"10\" name=\"article\" onkeyup=\"textLimit(this, 500)\">{$row['article']}</textarea><br />"; echo "<input type=\"submit\" />"; echo "</form>"; i know they are coming to this page as the data is need to connect to the db and that is working fine. the id is being passed to the next page as i have echoed this out. the are received on this page with this code $id = $_POST['id']; $db = $_POST['dropdown2']; $table = $_POST['radio2']; Quote Link to comment https://forums.phpfreaks.com/topic/129600-solved-posting-data/ Share on other sites More sharing options...
Maq Posted October 22, 2008 Share Posted October 22, 2008 Did you just modify it to say 2 instead of 3? I could have sworn you had the wrong names in the POST fields... Quote Link to comment https://forums.phpfreaks.com/topic/129600-solved-posting-data/#findComment-671856 Share on other sites More sharing options...
kev wood Posted October 22, 2008 Author Share Posted October 22, 2008 yes it i was messing around with it before i posted it up sorry for the confusion. it still not working any how. Quote Link to comment https://forums.phpfreaks.com/topic/129600-solved-posting-data/#findComment-671862 Share on other sites More sharing options...
Maq Posted October 22, 2008 Share Posted October 22, 2008 Well you're doing it correctly. I don't see any syntax errors, could you show me where these values are generated {$db['dropdown2']} {$table['radio2']} {$id['id']} Quote Link to comment https://forums.phpfreaks.com/topic/129600-solved-posting-data/#findComment-671866 Share on other sites More sharing options...
kev wood Posted October 22, 2008 Author Share Posted October 22, 2008 when i try to echo out the results i get an c for the db var and an i for the table var were it gets these from i do not know. here is the code were it is generated from <form action="edit.php" method="POST"> <select name="dropdown2"> <option value="constructiondb">Construction</option> <option value="electricaldb">Electrical</option> <option value="technicaldb">Technical</option> </select> <br /> <select name="radio2"> <option value="internal">Internal News</option> <option value="general">General News</option> </select> <br /> <input type="submit" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/129600-solved-posting-data/#findComment-671877 Share on other sites More sharing options...
Maq Posted October 22, 2008 Share Posted October 22, 2008 Oh I see, use these instead: $db['dropdown2'] = $db $table['radio2'] = $table $id['id'] = $id Quote Link to comment https://forums.phpfreaks.com/topic/129600-solved-posting-data/#findComment-671895 Share on other sites More sharing options...
kev wood Posted October 23, 2008 Author Share Posted October 23, 2008 no that still dont work i get array printed out on the screen now. Quote Link to comment https://forums.phpfreaks.com/topic/129600-solved-posting-data/#findComment-672595 Share on other sites More sharing options...
kev wood Posted October 23, 2008 Author Share Posted October 23, 2008 to get it to work in the section of code that has this value=\"{$db['dropdown2']}\" i simply changed it to this value=\"$db\ the only reason i can think that it didnt work was to do with the information i was trying to pass on again was already being passed to this page using hidden form data. if you can explain to me why this was happening that would be nice because although i have fixed it i do not understand what was causing the problem in the first place. Quote Link to comment https://forums.phpfreaks.com/topic/129600-solved-posting-data/#findComment-672662 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.