[eluser]jvittetoe[/eluser]
i am trying to figure out the basic pipeline for a simple login process. users come to the home page, which loads the home controller and home view. the home view contains a simple form for logging in. when they submit, i load the login controller which loads the login model which queries the useraccounts table in my database. if the user exists the login model will load the users dashboard view, if the user doesnt exist or bad info, the login model will load the home view again. is this the proper pipeline? let me post my files.
home view
Code:
<h2>Login In</h2>
<p>Fill out the form below to login to your account!</p>
<?php echo form_open('login');?>
<label for="username">Username</label><br />
<input type="text" name="username" id="username" /><br />
<label for="password">Password</label><br />
<input type="password" name="password" id="password" /><br />
<input type="submit" value="Login" />
</form>
login controller
Code:
<?php
class Login extends Controller{
function Login(){
parent::Controller();
$this->load->helper( array('url', 'form') );
}
function index(){
$this->load->model('Login_model','', TRUE);
$this->load->view('dashboard'); //send user to their dashboard
}
}
?>
login model
Code:
<?php
class Login_model extends Model{
function Login_model(){
parent::Model();
}
function login($username = '', $password = ''){
if($user){
$sql = $this->db->query("SELECT * FROM useraccounts WHERE usernamr = $username and password = md5($password)");
if($sql->num_rows() > 0){
return true;
}
} else {
return false;
}
/*
var $username = $_POST['username'];
var $password = $_POST['password'];
$sql = "SELECT uuid ";
$sql .= "FROM useraccounts ";
$sql .= "WHERE username='$username' AND password=MD5('$password') ";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$uuid = $row['uuid'];
if($uuid > 0) {
session_start();
$_SESSION['logged_in'] = TRUE;
$data['title'] = "Welcome to MyFi ~ A Personal Finance Web Application // My Home";
$this->load->view('userHome', $data);
echo 'workeded';
echo $uuid;
echo $username;
echo $password;
}
else {
$this->load->view('login_v', $data);
echo 'brokeded';
echo $uuid;
echo $username;
echo $password;
}
*/
}
}
?>
these files are still pretty bare, i just want to amke sure im headed in the right direction and i have the basic concepts down. thanks.