I have a question for php. I am sure it has already answered but I can't express it to search.
So, I have a page which is actually a user profile. In this page there is a button.
When I press this key I want somehow to take the id of the user the the profile belongs.
I think in jsp you can do this with Request object, but I am not sure.
If it's a form submit put the user id in a hidden input on the page. Something like:
<input type="hidden" name="user_id" value="<?php echo $your_user_id; ?>" />
Then when you click the button to submit your form it will be available in the variable
$_POST['user_id'] if you used the POST method or
$_GET['user_id'] if you used the GET method.
Are you running your page in a framework? Do you use sessions?
Php doesn't store any information about the page or user object unless you tell it to.
If you however have an object with userdata you can simply access it like this
And if there are some data in and userId property you might access it like this