longhornn Posted November 20, 2010 Share Posted November 20, 2010 Hi! I am trying to implement the comment feature. After a user selects a recipe from the search results (http://razor.ischool.utexas.edu/~nem/project/index.php scroll down to choose a recipe from the search results), the recipe page is displayed. The user may leave a comment at the bottom of the recipe page if she wishes to. The comment would be recorded in a mysql table and be displayed along with other comments for this particular recipe. The problem is that when the user has entered the comment and name and hits "Add my comment", this error appears: Notice: Undefined index: id in /.../recipeText_w.php on line 57 error retrieving proteins data While I understand it happens because the recipe Id ($_GET['id']) becomes unavailable after the comment and name are submitted, I am not sure how to make the recipe ID available again so that the same recipe page is displayed. The script is attached. I will appreciate your advice. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/219305-retrieve-_get-var-again-after-it-has-been-retrieved/ Share on other sites More sharing options...
requinix Posted November 20, 2010 Share Posted November 20, 2010 Unless you put the id= in the URL again, it won't be there for the next script to access it. Suggestion: use a hidden with the ID in the form. Then you'll access it with $_POST instead of $_GET. Link to comment https://forums.phpfreaks.com/topic/219305-retrieve-_get-var-again-after-it-has-been-retrieved/#findComment-1137260 Share on other sites More sharing options...
longhornn Posted November 20, 2010 Author Share Posted November 20, 2010 I thought about using 'hidden', too. Will try. Thanks! Link to comment https://forums.phpfreaks.com/topic/219305-retrieve-_get-var-again-after-it-has-been-retrieved/#findComment-1137265 Share on other sites More sharing options...
litebearer Posted November 21, 2010 Share Posted November 21, 2010 might also look into using a session variable Link to comment https://forums.phpfreaks.com/topic/219305-retrieve-_get-var-again-after-it-has-been-retrieved/#findComment-1137301 Share on other sites More sharing options...
requinix Posted November 21, 2010 Share Posted November 21, 2010 might also look into using a session variable If you can guarantee that somebody won't have two tabs for the site open at once, sure. Link to comment https://forums.phpfreaks.com/topic/219305-retrieve-_get-var-again-after-it-has-been-retrieved/#findComment-1137312 Share on other sites More sharing options...
longhornn Posted November 21, 2010 Author Share Posted November 21, 2010 I eventually used setcookie (). It helped. Thanks everybody! Link to comment https://forums.phpfreaks.com/topic/219305-retrieve-_get-var-again-after-it-has-been-retrieved/#findComment-1137313 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.