Hello,
I have a form witch only registered users can access (thanks to the guide at http://calguy1000.com/uploads/1/Hiding_ ... e-pdf.html) and the content of the form is saved in the database. Now i want to add the username to each record, so i tried something like:
$SQL = " INSERT INTO mytable ";
$SQL = $SQL . " (name, somevalue, username) VALUES ";
$SQL = $SQL . " ('$name', '$somevalue', '$customcontent_loginname') ";
but the username field is always empty (rest of the data is saved).
I'm new to everything (php, CMSMS, smarty) so can someone please explain how i can save the username in the database (later i will need it to select only the records the registered user has entered).
Thank you.
I'm using FEU 1.12.16 and CustomContent 1.7.3
customcontent_loginname question [solved]
-
- New Member
- Posts: 3
- Joined: Fri Jun 10, 2011 5:26 pm
customcontent_loginname question [solved]
Last edited by florinmarta on Wed Jun 15, 2011 12:09 pm, edited 1 time in total.
-
- New Member
- Posts: 3
- Joined: Fri Jun 10, 2011 5:26 pm
Re: customcontent_loginname question
I've created a UDF named myudt_username :
global $gCms;
$tpl_vars=$gCms->smarty->get_template_vars('ccuser');
$property = $tpl_vars->username();
return $property;
then defined a hidden property of the form:
<INPUT TYPE=hidden NAME=myusername VALUE={myudt_username}>
then used the hidden parameter in the SQL query
to get the IP you can use:
global $gCms;
$tpl_vars=$gCms->smarty->get_template_vars('customcontent_ip');
return $tpl_vars;
No other example worked for me, including the oness in the CMS made simple UDF documentations.
global $gCms;
$tpl_vars=$gCms->smarty->get_template_vars('ccuser');
$property = $tpl_vars->username();
return $property;
then defined a hidden property of the form:
<INPUT TYPE=hidden NAME=myusername VALUE={myudt_username}>
then used the hidden parameter in the SQL query
to get the IP you can use:
global $gCms;
$tpl_vars=$gCms->smarty->get_template_vars('customcontent_ip');
return $tpl_vars;
No other example worked for me, including the oness in the CMS made simple UDF documentations.
Re: customcontent_loginname question [solved]
I had a similar problem. The following worked for me.
In your form, save the $ccuser->loggedin() id to a hidden field, eg my-sql-field. That means that only the logged-in user's id is saved.
Then in your display template, use (as described in the FEU help) put:
hth
psy
In your form, save the $ccuser->loggedin() id to a hidden field, eg my-sql-field. That means that only the logged-in user's id is saved.
Then in your display template, use (as described in the FEU help) put:
Code: Select all
{$feu_smarty->get_user_properties($my-sql-field,'userprops')}{$userprops.firstname} {$userprops.lastname}
psy