1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Webslesson | <?php echo $title; ?></title>
5 <link rel="stylesheet"
6
7href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
8 </head>
9 <body>
10 <div class="container">
11 <br /><br /><br />
12 <form method="post" action="<?php echo base_url(); ?>main/login_validation">
13 <div class="form-group">
14 <label>Enter Username</label>
15 <input type="text" name="username" class="form-control" />
16 <span class="text-danger"><?php echo form_error('username'); ?
17
18></span>
19 </div>
20 <div class="form-group">
21 <label>Enter Password</label>
22 <input type="password" name="password" class="form-control" />
23 <span class="text-danger"><?php echo form_error('password'); ?
24
25></span>
26 </div>
27 <div class="form-group">
28 <input type="submit" name="insert" value="Login" class="btn btn-info" />
29 <?php
30 echo '<label class="text-danger">'.$this->session->flashdata
31
32("error").'</label>';
33 ?>
34 </div>
35 </form>
36 </div>
37 </body>
38 </html>
39
1 <?php
2 class Main_model extends CI_Model
3 {
4 function can_login($username, $password)
5 {
6 $this->db->where('username', $username);
7 $this->db->where('password', $password);
8 $query = $this->db->get('users');
9 //SELECT * FROM users WHERE username = '$username' AND password = '$password'
10 if($query->num_rows() > 0)
11 {
12 return true;
13 }
14 else
15 {
16 return false;
17 }
18 }
19 }
20