need help please

10 views
Skip to first unread message

abdelwahed mohamed

unread,
Apr 22, 2011, 1:31:58 PM4/22/11
to rainframework
hello rain team i try to create a login systeme using ajax here is my
form.Ajax function

function login(){

$username=$_GET['username'];
$password=$_GET['password'];
$db = new DB;

$result=$db->num_rows("SELECT * FROM user WHERE
pseudo='$username' AND pass=$password");
$this->ajax_mode( true, true );

if($result==1){
User::login($username, $password, $enable_cookies = true,
get("logout"));

}

else{

echo "erreur";

}

}

and here is my content controller code

function index(){
if( User::get_user_id() ){
echo 'User is connected';
}
else{
$this->load_library( "Form", "form" );
$this->form->init_form( URL . "ajax.php/form/login/", "get" );
$this->form->open_table( "connexion" );
$this->form->add_item( 'text', 'username', 'username', 'username',
null, 'required' );
$this->form->add_item( 'password', 'password', 'password', 'votre
mot de pass' );
$this->form->add_button();
$this->form->close_table();
$this->form->draw( $use_ajax = true, $return_string = false );

}


}

}

Rain

unread,
Apr 22, 2011, 6:33:42 PM4/22/11
to rainframework
instead of:

$result=$db->num_rows("SELECT * FROM user WHERE pseudo='$username'
AND pass=$password");
$this->ajax_mode( true, true );

if($result==1){
User::login($username, $password, $enable_cookies = true,
get("logout"));


just do
if( User::get_user_id() )
echo 'ok';
else
echo 'error';


Because in the application_bootstrap.php class, is called the method
loader::login() that authenticate the user.
Let us know if you still have problem.

We will publish soon the new version of the framework, with more
examples and probably new video tutorial

abdelwahed mohamed

unread,
Apr 22, 2011, 7:58:13 PM4/22/11
to rainframework
i cant understand i create a login form with two input username and
password and then i check if there is a row that conatin the
information entred by the user if he has an account else he register a
new account

Federico Ulfo

unread,
Apr 23, 2011, 4:11:34 AM4/23/11
to rainfr...@googlegroups.com
That should works. Just save the pw in md5 for better security. Soon the new version with login example in it.

2011/4/23 abdelwahed mohamed <bizert...@gmail.com>
Reply all
Reply to author
Forward
0 new messages