studgate Posted August 28, 2007 Share Posted August 28, 2007 I have three forms in my database, when each form is submitted the current username is automatically entered into the database, and I want the user to be able to edit only their entries. Everybody can view the entries but only them can update it. How do I do that?? Thanks in advance guys Link to comment https://forums.phpfreaks.com/topic/67068-allow-users-to-update-only-their-own-entries/ Share on other sites More sharing options...
frost Posted August 28, 2007 Share Posted August 28, 2007 Well I assume you are making people login? Once logged in you can use a cookie or session to store the username, then you can pull only the relevant entries from your database based on that name. Link to comment https://forums.phpfreaks.com/topic/67068-allow-users-to-update-only-their-own-entries/#findComment-336320 Share on other sites More sharing options...
datafan Posted August 28, 2007 Share Posted August 28, 2007 You could set a cookie at login like this: $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 7200; setcookie(ID_yoursitename, $_POST['username'], $hour,'/'); Then check to make sure it's there like this: if(isset($_COOKIE['ID_yoursitename'])) { do something } And you gotta do the cookie stuff before you output anything to the browser in your script. Link to comment https://forums.phpfreaks.com/topic/67068-allow-users-to-update-only-their-own-entries/#findComment-336324 Share on other sites More sharing options...
Jessica Posted August 28, 2007 Share Posted August 28, 2007 Of course, cookies can be edited, so you'll need to use sessions instead or at least in conjunction with. Link to comment https://forums.phpfreaks.com/topic/67068-allow-users-to-update-only-their-own-entries/#findComment-336329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.