Forums

Autogenerate tab

shivananda 30 Jul, 2007
Hi All,

the auto generate tab cannot insert data into morethan onetable.

I went to auto generate tab and i have added two more insert statement.But they r not working.If i keep any one them then the that statement is only executing.

Can anybody help me please.

Shiva.
GreyHead 30 Jul, 2007
Hi Shiva,

You can't autogenerate entries to more than one table but if you put a second complete INSERT query into the 'Auto generated' field that should work OK.

Please will you post the code from your 'Auto generated' field here for us to look at. Thanks.

Bob
shivananda 30 Jul, 2007
<?php
global $mainframe, $database, $my;
global $mosConfig_live_site;
global $Itemid;
//This is the default auto generated code
$database->setQuery( "INSERT INTO #__chronoforms_4 VALUES (
'' , '". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' , '".$_POST['user_reg_frm']."' , '".$_POST['gender']."' , '".$_POST['firstname']."' , '".$_POST['lastname']."' , '".$_POST['address']."' , '".$_POST['city']."' , '".$_POST['state']."' , '".$_POST['country']."' , '".$_POST['zip']."' , '".$_POST['phone']."' , '".$_POST['country0']."' , '".$_POST['email0']."' , '".$_POST['email1']."' , '".$_POST['email2']."' , '".$_POST['password']."' , '".$_POST['passwordConfirm']."' , '".$_POST['bMonth']."' , '".$_POST['bDay']."' , '".$_POST['bYear']."' , '".$_POST['00N30000001VGOk']."' , '".$_POST['00N30000001VGOl']."' , '".$_POST['00N30000001VGNX']."' , '".$_POST['00N30000001Yspe']."' , '".$_POST['CAPTCHAResponse']."' , '".$_POST['email']."' , '".$_POST['acknowdge_terms']."' , '".$_POST['privacy_policy']."' , '".$_POST['purchase_agreement']."' , '".$_POST['submit']."' , '".$_POST['sponsor_id']."');" );


This is my code

$database->setQuery( "INSERT INTO #__users(name,username,email,password,usertype,gid,registerDate) VALUES ( '".$_POST['firstname']."' , '".$_POST['lastname']."' ,'".$_POST['email0']."','".MD5($_POST['password'])."','Registered','18','". date('Y-m-d')."')");

$value=mysql_insert_id();

$database->setQuery( "INSERT INTO #__core_acl_aro(section_value,value,order_value,name,hidden) VALUES('users','$value','0','".$_POST['firstname']."' ,'0')");



if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}

?>

Bob i am trying to insert the username and password into the above two tables in order to login into the joomla from the username and password which i have creatd with the help of chrono forms.

Thanks

Shiva<br><br>Post edited by: shivananda, at: 2007/07/30 13:43
shivananda 30 Jul, 2007
Bob,

can u give me a clue please.

Thanks.
Shiva
GreyHead 30 Jul, 2007
Hi shiva,

A quick first response - I have something else to do now, I'll look in more detail later.

$database->setQuery() just sets the query it doesn't execute it. You'll need to run $database->query() after each setQuery - with the code here only the last query is being run.

As a side comment; personally I prefer the SET syntax to the VALUES syntax when developing queries as it makes it much clearer what's happening. For example:
INSERT 
  INTO #__core_acl_aro
  SET section_value = 'users',
      value         = '$value',
      order_value   = '0',
      name          = '".$_POST['firstname']."',
      hidden        = '0';
Bob
shivananda 30 Jul, 2007
Grey,

Atlast,I got way to my solution.Now i am able to login with the user name and password which r registered in chrono created register form.And it is working.
But,in the user Manager(from admin side) of joomla it is not showing chronocreated register users.If the user is chrono user it is displays
"logged in as admin".

my code looks like this

mysql_query("INSERT INTO isn_users(username,name,email,password,usertype,gid,registerDate) VALUES ( '".$_POST['firstname']."' , '".$_POST['lastname']."' ,'".$_POST['email0']."','".MD5($_POST['password'])."','Registered','18','". date('Y-m-d')."')");
$value=mysql_insert_id();

mysql_query("INSERT INTO isn_core_acl_aro(section_value,value,order_value,name,hidden) VALUES('users','$value','0','".$_POST['lastname']."' ,'0')");
.

Do you have any idea about this.

Thanks for your major help Grey

Shiva<br><br>Post edited by: shivananda, at: 2007/07/30 17:06
shivananda 30 Jul, 2007
Thank u Grey,

i am able to show usernames in the admin panel also.

Shiva
GreyHead 31 Jul, 2007
Hi Shiva,

Well done, glad you got it all working.

I still have some concerns about this way of registering users as I think you are by-passing some of the regular registrations checks like looking for duplicate user names. You may just need to duplicate more of that code as time goes on.

Bob
shivananda 31 Jul, 2007
Bob,

may b you are Right .But i am checking the usernames and emails for uniqueness at the time of submitting the form.

Shiva.
This topic is locked and no more replies can be posted.