GET form method and accessing its value into a cookie

From: Date: Thu, 21 Jul 2005 09:38:14 +0000
Subject: GET form method and accessing its value into a cookie
Groups: php.general 
Request: Send a blank email to php-general+get-219113@lists.php.net to get a copy of this message
Hi I have a page which generates 'edit' links (used to edit user details). The code snippet on the 'list_user.php' page is; --- $print_rows .=    "<tr class=\"stdtablecells\"> \n".                                 "   <td>{$details['name']}</td> \n".                                 "   <td>{$details['mail']}</td> \n".                                 "   <td>{$details['quota']}</td> \n".                                 "   <td><a href=\"edit_user.php?user={$user_list[$i]['uid'][0]}\">edit</a></td> \n".                                 "</tr> \n"; --- The line in question really is this one; <a href=\"edit_user.php?user={$user_list[$i]['uid'][0]}\">edit</a></td> \n". As you can see this creates a link to the 'edit_user.php' page with a GET parameter generated by a php array. The 'edit_user.php' page contains this script (before any headers are generated) which is designed to put the GET value into a cookie; --- if (! isset($_COOKIE['yhgfluseruid'])) {     $useruid = $_REQUEST['user'];     setcookie('yhgfluseruid', $useruid); } --- What happens when actually viewing the pages in a browser, is that the url is generated (seemingly) correctly, for example; http://localhost/emailadmin/src/edit_user.php?user=paul.bradley@eriding.net The only problem is the $user variable doesn't seem to read the cookie, or the cookie doesn't get generated before the rest of the page is generated and the users details are blank. BUT if I refresh the page, everything is fine. Also, if I go back to the 'list_user.php' page, and try editing a different user, although the URL suggests that it's passing the correct parameters, I end up seeing the details of the previous user? Help please (sorry for the long description - I am just trying to be accurate) Regards Steve

« previous php.general (#219113) next »