Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.