06-22-2018, 11:23 AM
Yes. That works. The thing you risk is that someone could change it. If it were me, I would try 2 more things.
I would add the word readonly to the end of the input
but then, to be honest, if on form submission I would not even look at what's inputted on the form input. I would just do
Unless you really want them to be able to put something other than their username in there, because even with readonly, they could post a different username (like admin).
I would add the word readonly to the end of the input
Code:
<input type="text" name="user" value="<?=$user->data()->id?>" readonly>
but then, to be honest, if on form submission I would not even look at what's inputted on the form input. I would just do
Code:
$username = $user->data()->username;
Unless you really want them to be able to put something other than their username in there, because even with readonly, they could post a different username (like admin).