require_once "../raxandev10/raxan/pdi/autostart.php";
class HomePage extends RaxanWebPage {
protected $db;
protected function _authorize() {
$isLogin = Raxan::data('MySession','isLogin');
if ($isLogin){
$this['#form-right']->html('<div class="success">You already logged in.</div>');
}
return true;
}
protected function _init() {
$this->source('view/index.html');
$this->db = $this->Raxan->connect('mysql:host=localhost; dbname=appol','root','',true);
if (!$this->db){
$this->halt('<h2>Unable to connect to the MySQL Database.</h2>');
}
}
protected function _load() {
$examples = Raxan::importCSV('examples.csv');
$this->list->bind($examples);
}
protected function login($e) { // event callback
$msg = array();
$data = $this->sanitizePostBack();
$usr = $data->value('username');
$pwd = $data->value('password');
$cmp = $data->value('company');
// validate user input
if (!$cmp) $msg[] ='Please enter a valid Company name.';
if (!$usr) $msg[] ='Please enter your user name.';
if (!$pwd) $msg[] ='Please enter a valid password.';
$this['#form-right']->html('Record sucessfully removed','bounce','notice');
$data = $this->db->table("dbuser userid,username,password,dbname","username=?","'".$usr."'");
if (strtolower($data[2])==strtolower($pwd) && strtolower($data[3])==strtolower($cmp)){
Raxan::data('MySession','isLogin',true);
$this['#form-right']->html('<div class="success">Login was successfull.</div>');
}else{
$msg = '<strong>'.implode('<br />',$msg).'</strong>';
$this['#form-right']->html($msg)->show();
}
}
protected function logout($e) {
Raxan::removeData('MySession','isLogin');
$this->redirectTo('index.php');
}
}
<form id="form1" name="form1" action="" method="post">
<H2>Login Form</H2>
<div id="form-left">
<legend>Login</legend>
<input type="text" name="company" id="company" value="" class="tip-form" title="Required" onfocus="if(this.value=='Company')this.value='';" onblur="if(this.value=='')this.value='Company';" value="Company" class="tip-form"/>
<input type="text" name="username" id="username" value="" class="tip-form" title="Required" onfocus="if(this.value=='User Name')this.value='';" onblur="if(this.value=='')this.value='User Name';" value="User Name" class="tip-form"/>
<input type="text" name="password" id="password" value="" class="tip-form" title="Required" onfocus="if(this.value=='Password')this.value='';" onblur="if(this.value=='')this.value='Password';" value="Password" class="tip-form"/>
</div>
<div id="form-right">test</div>
<input type="submit" value="Login" xt-bind="click,login"/>
</form>
noviandi_pakuan wrote:needed help,
i download login-demo yesterday and try to implement it with a few modification but it's not work, please give me your suggest and fix if i'am wrong ...
i use raxan for developer 201006
<?php
require_once "raxan-devsnap/pdi/autostart.php";
class HomePage extends RaxanWebPage {
protected $db;
protected function _init() {
$this->source('views/index.html');
$this->loadCSS('master');
$this->preserveFormContent = true;
try {
$this->db = $this->Raxan->connect('mysql:host=localhost; dbname=test', 'user', 'password', true);
} catch(Exception $e){
$this->halt('<h2>Unable to connect to the MySQL Database.</h2>');
}
}
protected function _authorize() {
$isLogin = Raxan::data('MySession', 'isLogin');
if ($isLogin) {
$this['#form-right']->html('<div class="box success">You already logged in.</div>');
}
return true;
}
protected function login($e) { // event callback
$msg = array();
$data = $this->sanitizePostBack();
$usr = $data->value('username');
$pwd = $data->value('password');
$cmp = $data->value('company');
// validate user input
if (!$cmp)
$msg[] = 'Please enter a valid Company name.';
if (!$usr)
$msg[] = 'Please enter your user name.';
if (!$pwd)
$msg[] = 'Please enter a valid password.';
// display validation message
if ($msg) {
$msg = '<strong>' . implode('<br />', $msg) . '</strong>';
$this['#form-right']->html('<div class="box error">'.$msg.'</div>')->show();
return ;
}
// search database for user name
try {
$data = $this->db->table("users userid,username,password,company", "username=?", $usr);
} catch(Exception $e) {
$this['#form-right']->html('<div class="error">Error while logging in. Please try again.</div>');
return;
}
if ($data && strtolower($data[0]['password']) == strtolower($pwd) && strtolower($data[0]['company']) == strtolower($cmp)) {
// login ok
Raxan::data('MySession', 'isLogin', true);
$this['#form-right']->html('<div class="box success">Login was successful.</div>');
}
else {
// login failed
$this['#form-right']->html('<div class="box error">Login was unsuccessful.</div>');
}
}
protected function logout($e) {
Raxan::removeData('MySession', 'isLogin');
$this->redirectTo('index.php');
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Login Test</title>
</head>
<body>
<form id="form1" name="form1" action="" method="post" >
<div id="form-left" class="container c20">
<H2>Login Form</H2>
<legend>Login</legend>
<input type="text" name="company" id="company" value="" class="tip-form" title="Required" onfocus="if(this.value=='Company')this.value='';" onblur="if(this.value=='')this.value='Company';" value="Company" class="tip-form"/>
<input type="text" name="username" id="username" value="" class="tip-form" title="Required" onfocus="if(this.value=='User Name')this.value='';" onblur="if(this.value=='')this.value='User Name';" value="User Name" class="tip-form"/>
<input type="text" name="password" id="password" value="" class="tip-form" title="Required" onfocus="if(this.value=='Password')this.value='';" onblur="if(this.value=='')this.value='Password';" value="Password" class="tip-form"/>
<div id="form-right" class="tpm bmm">test</div>
<input type="submit" value="Login" xt-bind="click,login"/>
</div>
</form>
</body>
</html>
is there anything wrong with authentication code ??you already login
$dns = 'mysql:host=localhost;dbname=appol';
$db = Raxan::connect($dns,'root','',true);
Uncaught Error: Page element 'noteList' or property not found Line 323 in E:\EasyPHP\www\raxandev10asli\raxan\pdi\shared\raxan.webpage.php
#0 E:\EasyPHP\www\raxandev10asli\examples\notes.php(29): RaxanWebPage->__get('noteList')
#1 E:\EasyPHP\www\raxandev10asli\raxan\pdi\shared\raxan.webpage.php(254): NotesPage->_indexView()
#2 E:\EasyPHP\www\raxandev10asli\raxan\pdi\autostart.php(68): RaxanWebPage->__construct('')
#3 E:\EasyPHP\www\raxandev10asli\raxan\pdi\autostart.php(55): raxan_auto_create('NotesPage', '')
#4 [internal function]: raxan_auto_startup('E:\EasyPHP\www\...')
#5 {main}
noviandi_pakuan wrote:1. when firts i load the page, the "form-right" has a text like "you already login" is there anything wrong with authentication code ??
<?php
require_once "raxan/pdi/autostart.php";
class HomePage extends RaxanWebPage {
protected $db;
protected function _init() {
$this->source('views/index.html');
$this->loadCSS('master');
$this->preserveFormContent = true;
try {
$user = 'root';
$password = '';
$dsn = 'mysql:host=localhost; dbname=appol';
$this->db = Raxan::connect($dsn, $user, $password, true);
} catch(Exception $e){
$this->halt('<h2>Unable to connect to the MySQL Database.</h2>');
}
}
protected function _authorize() {
$isLogin = Raxan::data('isLogin');
if ($isLogin) {
$this['#form-right']->html('<div class="box success">You already logged in.</div>');
}
return true;
}
protected function login($e) { // event callback
$msg = array();
$usr = $this->post->value('username');
$pwd = $this->post->value('password');
$cmp = $this->post->value('company');
// validate user input
if (!$cmp)
$msg[] = 'Please enter a valid Company name.';
if (!$usr)
$msg[] = 'Please enter your user name.';
if (!$pwd)
$msg[] = 'Please enter a valid password.';
// display validation message
if ($msg) {
$msg = '<strong>' . implode('<br />', $msg) . '</strong>';
$this['#form-right']->html('<div class="box error">'.$msg.'</div>')->show();
return ;
}
// search database for user name
try {
$data = $this->db->table("users userid,username,password,company", "username=?", $usr);
} catch(Exception $e) {
$this['#form-right']->html('<div class="error">Error while logging in. Please try again.</div>');
return;
}
if ($data && strtolower($data[0]['password']) == strtolower($pwd) && strtolower($data[0]['company']) == strtolower($cmp)) {
// login ok
Raxan::data('isLogin', true);
$this['#form-right']->html('<div class="box success">Login was successful.</div>');
}
else {
// login failed
$this['#form-right']->html('<div class="box error">Login was unsuccessful.</div>');
}
}
protected function logout($e) {
Raxan::removeData('isLogin');
$this->redirectTo('index.php');
}
}
?>
3. when i click submit, it's not success bind to function login, i try to put halt to see if it work but it not show at all...
4. when i try other sample like notes.php which include in developer20100614 it not work with error like this ..
Uncaught Error: Page element 'noteList' or property not found Line 323 in E:\EasyPHP\www\raxandev10asli\raxan\pdi\shared\raxan.webpage.php
#0 E:\EasyPHP\www\raxandev10asli\examples\notes.php(29): RaxanWebPage->__get('noteList')
#1 E:\EasyPHP\www\raxandev10asli\raxan\pdi\shared\raxan.webpage.php(254): NotesPage->_indexView()
#2 E:\EasyPHP\www\raxandev10asli\raxan\pdi\autostart.php(68): RaxanWebPage->__construct('')
#3 E:\EasyPHP\www\raxandev10asli\raxan\pdi\autostart.php(55): raxan_auto_create('NotesPage', '')
#4 [internal function]: raxan_auto_startup('E:\EasyPHP\www\...')
#5 {main}
5. could you tell us the newbie, a newest raxan framework that can be use with php-exampes and develover examples, cause when i use raxan 10 beta 3 and put the developer example it alway's error like Question no.4
and for developer example when use in beta 3 it just output
Render Time: 0.00070595741271973
without any picture at all ...
i hope you're not bored if i asking some question in raxan framework....
Users browsing this forum: No registered users and 1 guest