And here is my auto generated code:setQuery( "INSERT INTO #__chronoforms_8 VALUES ('' , '".$inum."', '". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' , '".mosGetParam($_POST,'date','')."' , '".mosGetParam($_POST,'name','')."' , '".mosGetParam($_POST,'UnderstandAgree','')."' , '".mosGetParam($_POST,'NoReasonWhy','')."');" );if (!$database->query()) {echo " alert('".$database->getErrorMsg()."'); window.history.go(-1);";}?>I have selected the profile plugin and here are my field choices:Table name: mos_users REQUEST Parameter name: name Target field name: name Can sonmeone PLEASE help me, am slowly going insane trying to figure this one out.. I searched the forum but am still having issues"> I messed up my form :O( record username on submit - Forums

Forums

I messed up my form :O( record username on submit

MistaT2000 02 Feb, 2009
Hi Folks!

Ok i'm using Mambo but managed to get chronoforms (j 1.0) version working fine...

What I wanted to do was have a very simple form... basically its for recording which users have read a document and if they agree/disagree with the content... I had a simple dropdown for them to select their username but since then they want to record the username automatically 🙄

So I had my form setup and it was working fine under the username...they then wanted me to record the users 'name' as the users had chosen their usernames themselves and they didnt make alot on sense...

SO i tried to re-work the form (i didnt back it up 😢 ) and now i have broken it and cant even get the username out now 🤣

In my form code i have added

<input type="hidden" name="name" value="<?php echo $my->name; ?>" />


And here is my auto generated code:

<?php 
   global $database;
   global $my;
   srand((double)microtime()*10000);
   $inum   =   "I" . substr(base64_encode(md5(rand())), 0, 16);
   
    

$database->setQuery( "INSERT INTO #__chronoforms_8 VALUES  (
'' , '".$inum."', '". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' , '".mosGetParam($_POST,'date','')."' , '".mosGetParam
($_POST,'name','')."' , '".mosGetParam
($_POST,'UnderstandAgree','')."' , '".mosGetParam
($_POST,'NoReasonWhy','')."');" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1);
</script>
";
}
?>


I have selected the profile plugin and here are my field choices:

Table name:    mos_users 
 REQUEST Parameter name: name  
 Target field name:   name
      


Can sonmeone PLEASE help me, am slowly going insane trying to figure this one out.. I searched the forum but am still having issues
MistaT2000 02 Feb, 2009
Ok... progress 🙂

I have now managed to get the username field to populate... my problem again is getting the 'name' field

I change username to name in my form code but it wont give me the information... how come? 😲 :?
Max_admin 02 Feb, 2009
Hi Mista,

Glad you made some progress, the $my variable in J1.0 and of course Mambo doesn't have "name" property I think, you will need to use $my->id and query the mos_users table to get the user's name!

Regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
MistaT2000 03 Feb, 2009
Hi Admin!

I had a wee look at the mos_users table and there is a 'name' column.. is the reason i cant call it because its not held withing the global $my variable?

I tried 'id' and it just returns a numeric value 😟

Even if i could return the email field that would be a start but i cant seem to grab any of these other values stored within the mos_users table...
Max_admin 03 Feb, 2009
Hi Mista,

As I said, you need to use this $my->id to get the user data from the table, you need SQL SELECT statement, here is an example :


global $database, $my;
$query = "SELECT * FROM #__users WHERE id = '".$my->id."'";
$database->setQuery( $query );
$userdata = $database->loadObject();
echo $userdata->name;
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
MistaT2000 05 Feb, 2009

Hi Mista,

As I said, you need to use this $my->id to get the user data from the table, you need SQL SELECT statement, here is an example :


global $database, $my;
$query = "SELECT * FROM #__users WHERE id = '".$my->id."'";
$database->setQuery( $query );
$userdata = $database->loadObject();
echo $userdata->name;



Hi Admin!

Thanks for the reply, any idea how i would structure this in my autogenerated code? Also would i need to select 'name' column from the mos_users table in the profile page plugin?

Thanks for your help!

MistaT
Max_admin 05 Feb, 2009
Hi Mista,

if you are going to use this in the autogenerated box then you just copy and paste, use the $userdata->name in the correct place though!

why do you need the profile plugin ?

Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.