Hi.
I'm currently using:
to restrict a form to registered and logged in users only.
I'm wondering if there is any way to save the username of that user in a table, without having them entering it?
How do I "get" the username, and how do I create that table. Should I do it in phpMyAdmin?
Thanks in advance!
I'm currently using:
<?php
$user = &JFactory::getUser();
if(!$user->id){return;}
?>
to restrict a form to registered and logged in users only.
I'm wondering if there is any way to save the username of that user in a table, without having them entering it?
How do I "get" the username, and how do I create that table. Should I do it in phpMyAdmin?
Thanks in advance!
Hi Kizo,
You can make a hidden field at your html called "username", then you create a table for your form, check the username box, now you have a column called username, at the HTML of your form, add this code in the value attribute of your username field :
You can make a hidden field at your html called "username", then you create a table for your form, check the username box, now you have a column called username, at the HTML of your form, add this code in the value attribute of your username field :
<?php
$user = &JFactory::getUser();
echo $user->username;
?>
admin wrote:
How do you suggest I hide it?
Thank you.
You can make a hidden field at your html called "username"
How do you suggest I hide it?
Thank you.
its already hidden, its a "hidden" field, something like this :
;)
<input type="hidden" name="username">
;)
Thanks Kizo!
This topic is locked and no more replies can be posted.