s_ainley87 Posted August 20, 2008 Share Posted August 20, 2008 Hello, I am currently trying to work something out in my head, I wanting to have a form that can add a user to a db and also edit the users. I want to use the same form for both tasks, but on the edit form on have the editable fields enabled. I am trying to work out the best way to ascertain whether the user is adding or editing a user. I thought about creating a function the creates a session called edit and then check for that session on my form page and if it matches run some javascript to disable the uneditable form fields. Or would a better way to do have so that if the user exists in the database it immediately goes to edit page with the disabled fields. Basically what I am asking is, it best to use a session or pass the user id, so it checks if it exists? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/120516-passing-id-and-showing-form-dependent-on-id/ Share on other sites More sharing options...
JonnoTheDev Posted August 20, 2008 Share Posted August 20, 2008 You can use any method as long as a flag is set to identify the mode you are in. Personally I would forget about using a session an use URL parameters ie: form.php?action=create form.php?action=edit&userId=5 You can use the action value and userId value within hidden fields in the form to retain the mode you are in an the user record you are editing Quote Link to comment https://forums.phpfreaks.com/topic/120516-passing-id-and-showing-form-dependent-on-id/#findComment-621035 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.