CodeIgniter Forums
database connectivity - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: database connectivity (/showthread.php?tid=53632)



database connectivity - El Forum - 08-01-2012

[eluser]Unknown[/eluser]
dear all i have the following controller

<?php

class Admin extends CI_Controller {

function __constructor(){
parent::__constructor();
} //constructor ended
public function index(){
$this->load->view('adminV');


} //index function ended
public function administrator(){
$this->load->model('admin_model','',TRUE);
$rzlt =$this->admin_model->login();}
}

?>


and have the following view


<html>
<head>
</head>
<body>


<form action="<?php echo base_url();?>admin/administrator" method="post" name="form">
<label> UserName</label>
&lt;input type="text" name="un" /&gt;
<label> Password </label>
&lt;input type="password" name="pass" /&gt;
&lt;input type="submit" value="submit" name="submit" /&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;



and model in the following as well
&lt;?php

class Admin_model extends CI_Model{


function __construct(){
parent::__construct();
}
public function db(){
echo "i m admin";
}
public function login(){
require "db.php";
$all = "SELECT * FROM admin"; //getting all data from the user
$use = $_POST['un'];
$pas =$_POST['pass'];
$sub = $_POST['submit'];
$rzlt= mysql_query($all);
while ($show = mysql_fetch_array($rzlt))
{

if($show['username']==$use && $show['password']==$pas)
{
echo "you are logged in as administrator";}
else
{
echo "plz try again to login";
}
}




}
}

?&gt;

and my other file of db contain the database connectivity only. after run this code m intnimate that the un, pas and submit are not defined.
any body is there to help me in this regard..
thnx in advance Wink