password protected button

Ask about general coding issues or problems here.

Moderators: gesf, Michalio

Post Reply
Dharmeshdhabu
New php-forum User
New php-forum User
Posts: 24
Joined: Sat Jul 23, 2022 6:45 pm

I have created php project for hospital management. I have a button to update patient data. I wish to protect update function with password, means when button is present, a pop up message should flash asking to enter password and upon entering correct password only, data should be updated. Please guide me.
User avatar
Michalio
Moderator
Moderator
Posts: 271
Joined: Sun Jul 18, 2021 1:33 pm
Location: Poland

Simply, add a new field for the password in your form and validate it on backend, if password is invalid then show error message and disallow to save the data in the database
Free coding lessons: https://php-forum.com/phpforum/viewtopic.php?t=29852
Dharmeshdhabu
New php-forum User
New php-forum User
Posts: 24
Joined: Sat Jul 23, 2022 6:45 pm

Yes, I have done the same, but I wish a pop up input box for password because at present if I put wrong password, it did not show message. Actually session message is shown when I go to some other page only. I don't know why this is happening. I have action="" means action on same page still message is not shown on same page. Please guide me.
User avatar
Michalio
Moderator
Moderator
Posts: 271
Joined: Sun Jul 18, 2021 1:33 pm
Location: Poland

if you have action="" then you can remove that attribute. You can add new password field and add validation on the same page to check the password.
It should be easy if you know the app code, so I don't know how to guide you to do that without basic knowledge of your code
Free coding lessons: https://php-forum.com/phpforum/viewtopic.php?t=29852
Dharmeshdhabu
New php-forum User
New php-forum User
Posts: 24
Joined: Sat Jul 23, 2022 6:45 pm

Michalio wrote: Wed Sep 21, 2022 6:45 am if you have action="" then you can remove that attribute. You can add new password field and add validation on the same page to check the password.
It should be easy if you know the app code, so I don't know how to guide you to do that without basic knowledge of your code
I used alert message instead of sessions message and problem is solved at present. What I want is a popup input box for password. Is there a way to get it?
User avatar
Michalio
Moderator
Moderator
Posts: 271
Joined: Sun Jul 18, 2021 1:33 pm
Location: Poland

You mentioned that you are using jquery, so there is a dialog component for that: https://jqueryui.com/dialog/#modal-form
Free coding lessons: https://php-forum.com/phpforum/viewtopic.php?t=29852
Post Reply