Skip to content

Instantly share code, notes, and snippets.

@unlobito unlobito/login.php
Created May 11, 2010

Embed
What would you like to do?
<?php
if (!isset($_POST['email']) or !isset($_POST['password'])) {
$token = sha1(time()+rand(1,9999999999));
$this->session->set_userdata('students_loginToken', $token);
$this->load->view('students_login', Array('token' => $token));
} else {
$query = $this->db->query("SELECT * FROM users WHERE email = '".$_POST['email']."'");
echo mysql_error();
if ($query->num_rows() == 0) {
$token = sha1(time()+rand(1,9999999999));
$this->session->set_userdata('students_loginToken', $token);
$this->load->view('students_login', Array('token' => $token, 'error' => '<center>Invalid Email or Password!</center>'));
} else {
$user = $query->row_array();
if (md5($user['password'].$this->session->userdata('students_loginToken')) == $_POST['password']) {
$this->session->set_userdata('students_user', $query->row_array());
header('Location: /students/home/');
} else {
$token = sha1(time()+rand(1,9999999999));
$this->session->set_userdata('students_loginToken', $token);
$this->load->view('students_login', Array('token' => $token, 'error' => '<center>Invalid Email or Password!</center>'));
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.