CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [Solved] Custom insert when login

Print topic Send  topic

Author Message
sorinbuda

Posts: 27
Posted: 05/05/2010, 5:37 AM

I've added the following script to the DoLoginButton
The script is inserting the User Login in a table and in this way I can build a statistic regarging the visitors of the intranet.

  
{  
  
  $db = new clsDBdatabasename();  
  $SQL = "INSERT INTO tablename (rowname) ".   
         "VALUES (". $db->ToSQL(CCGetUserLogin(),ccsText) .")";  
  
  $db->query($SQL);  
  $db->close();  
    
}  

However I need to see if there are people trying to access the intranet without permission or if there are registered users that try to access intranet and forgot the passord. That is why I have tryed the following script:

  
{  
  
  $db = new clsDBdatabasename();  
  $SQL = "INSERT INTO tablename (rowname) ".   
         "VALUES (". $db->ToSQL(CCGetFromGet("loginformfieldname"),ccsText) .")";  
  
  $db->query($SQL);  
  $db->close();  
    
}  

The result however is not the expected one. Instead of getting the loginformfieldvalue into the database I am getting NULL value.

I am using MySQL as database.

The second qwestion is How to insert the current date and time in the database.

Thank you in advance,
Sorin
View profile  Send private message
magus

Posts: 98
Posted: 05/15/2010, 10:25 AM

Hi Sorin,

The problem may be using double quotes for strings and the get parameter name.

Also I expect 'rowname' is a typo that is meant to read 'columnname'.

Try


{

$db = new clsDBdatabasename();
$SQL = "INSERT INTO tablename (columnname) ".
"VALUES (". $db->ToSQL(CCGetFromGet('loginformfieldname'),ccsText) .")";

$db->query($SQL);
$db->close();

}

Regards,
Don A
View profile  Send private message
jjrjr1


Posts: 942
Posted: 05/15/2010, 11:10 AM

Hi

You need to remember the basics of a transaction.

There are two sides of the thing and they are the GET and POST actions.

Since the login code executing is an on click event that means the code is executed on the POST action not the GET.

With that being said the CCSGetFromGet() function will not provide any data since it only has access to POST data.

To get the form field data on the POST action you need to use a different CCS function.

Try CCGetFromPost("loginformfieldname") which will get form POST data

or try CCGetParam("loginformfieldname") Which returns both GET and POST data.

Let me know if your results are better

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
melvyn


Posts: 333
Posted: 05/15/2010, 2:14 PM

For this purposes I insert a line in the grey area of Common.php and customize the CCLoginUser() function

I add code in that line, if you're carefull isn't dangerous.

There you don't need to use $_POST or $_GET, it's pretty easy.

----------------

If you try modifing the Login_Button_DoLogin_OnClick event, then try between the lines:
  
    if ( !CCLoginUser( $Container->login->Value, $Container->password->Value)) {  
        $Container->Errors->addError($CCSLocales->GetText("CCS_LoginError"));  
        $Container->password->SetValue("");  
        $Login_Button_DoLogin_OnClick = 0;  
        CCSetCookie("projects.purocodigo.com", "");  
  
// if login fail then place your code here  
  
    } else {  
        global $Redirect;  
        if ($Container->autoLogin->Value == $Container->autoLogin->CheckedValue) {  
            $ALLogin    = $Container->login->Value;  
            $ALPassword = $Container->password->Value;  
            CCSetALCookie($ALLogin, $ALPassword);  
        }  
        $Redirect = CCGetParam("ret_link", $Redirect);  
        $Login_Button_DoLogin_OnClick = 1;  
  
// if login succeed then place your code here   
  
    }  
I don't recommend this, meanwhile you're working in this area...
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 05/15/2010, 2:28 PM

If you want to approach it as Melvyn suggests

I would stay away from modifying the CCS standard code.

You might consider in the on click event add a new custom code action with the following code

if (CCGetUserID() > 0) //Check if logged in
{
global $Redirect;

//What ever logic you want:

//eg:

Your database update code for successful log in

}else{ // Not Logged In
global $Redirect;

Your unsuccessful db update code

}

Both will work but I like to stay away from modifying CCS Grey Areas..

LOL

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
sorinbuda

Posts: 27
Posted: 06/13/2010, 1:06 PM

Thank you for help,

Since I'm a rocky I prefer to stay out of the CCS grey zone. Therefore I followed the path indicated by jjrjr1. The solution looks as follows:


  
  
{  
  
  $db = new clsDBdatabasename();  
  $SQL = "INSERT INTO table_name (coloum_name1,coloum_name3,coloum_nameN) ".   
         "VALUES (". $db->ToSQL(CCGetParam("field1",0),ccsText) .",". $db->ToSQL(CCGetParam("field_name2",0),ccsText) .",". $db->ToSQL(CCGetParam("field_nameN",0),ccsText) .")";  
  
  $db->query($SQL);  
  $db->close();  
    
}  
  
  
  
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.