Welcome Guest, Not a member yet? Register   Sign In
having problem in Code
#1

[eluser]XPHARSH[/eluser]
controllers:-
login.php
Code:
<?php
class Login extends Controller {

    function Login()
    {
        parent::Controller();
        $this->load->database();
    }
    
    function index($wrong_log='')
    {
        $data['login_id'] = array('name' => 'loginid');
        $data['password'] = array('name' => 'pass', 'type' => 'password');
        $data['wrong_log'] = $wrong_log;
        $this->load->view('index_login',$data);
    }
    function login_chk()
    {
        $login_id = $this->input->post('loginid');
        $passwd = $this->input->post('pass');
        
        $query = $this->db->query('select * from login where user_id = ? and password = ?',array($login_id,$passwd));
        if($query->num_rows()>0)
        {
            $this->load->view('main');
        }
        else
        {
            $this->index("Error In Login");
        }
    }
}
?>

View :-
index_login.php
Code:
<html>
<head>
<title>Welcome to CodeIgniter</title>
</head>
<body>
<?php
if($wrong_log != "")
{
    echo "Wrong login Id password";
}
?>
<?php echo form_open('login/login_chk'); ?>
<table>
<tr>
<td>Login ID:</td>
<td>&lt;?php echo form_input($login_id); ?&gt;</td>
</tr>
<tr>
<td>Password:</td>
<td>&lt;?php echo form_input($password); ?&gt;</td>
</tr>
<tr>
<td></td>
<td>&lt;?php echo form_submit('submit','Submit'); ?&gt;</td>
</tr>
</table>
&lt;?php form_close(); ?&gt;
&lt;/body&gt;
&lt;/html&gt;

view:-
main.php
Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Welcome to CodeIgniter&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<h1>You are Logid in !!!!!!!!!!!</h1>
&lt;/body&gt;
&lt;/html&gt;

i am trying to make a login page.

if user put wrong password. then it will redirect it to login page with error message.
if user put correct id password then redirect to main.php

but i am getting an error in this code.

I am new to codeigniter Pl help me to resolve this error.
#2

[eluser]XPHARSH[/eluser]
ok now i have resolve the problem.

now i am facing some secularity problem here.

if user put wrong Id and password the user will redirect to index_login.php page with error messege.
but if he click go button on address bar 2 or 3 time with ought typing any ting in to Login and Password fiels after redirecting user will automatically switch to main.php page which is wrong.

so how to resolve this error?




Theme © iAndrew 2016 - Forum software by © MyBB