You are here: GET form method and accessing its value into a cookie « PHP Language « IT news, forums, messages
GET form method and accessing its value into a cookie

Posted by Steve on 07/21/05 12:54

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация