Save user-name to a table?

kizo 29 Oct, 2007
Hi.
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!
Max_admin 29 Oct, 2007
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 :



 <?php
$user = &JFactory::getUser();
echo $user->username;
?>
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
kizo 29 Oct, 2007
admin wrote:

You can make a hidden field at your html called "username"


How do you suggest I hide it?

Thank you.
Max_admin 29 Oct, 2007
its already hidden, its a "hidden" field, something like this :

<input type="hidden" name="username">


;)
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
kizo 29 Oct, 2007
Works great!
Once again, admin has saved the day.

Thank you!
Max_admin 30 Oct, 2007
Thanks Kizo!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger