Basic login, codeigniter
autoload
1 |
$autoload['libraries'] = array('database', 'session'); |
1 |
$autoload['helper'] = array('form','url'); |
controller login.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Login extends CI_Controller { public function __construct() { parent::__construct(); } public function check() { $emp_username=$this->input->post('emp_username'); $emp_password=$this->input->post('emp_password'); if($emp_username=='admin' && $emp_password=='admin'){ $data['result'] = "Login Successfully"; $this->load->view('loginok',$data); }else{ redirect('?act=F', 'refresh'); } } } |
view login form name = welcome_message.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?><!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Welcome to CodeIgniter</title> <style type="text/css"> ::selection { background-color: #E13300; color: white; } ::-moz-selection { background-color: #E13300; color: white; } body { background-color: #fff; margin: 40px; font: 13px/20px normal Helvetica, Arial, sans-serif; color: #4F5155; } a { color: #003399; background-color: transparent; font-weight: normal; } h1 { color: #444; background-color: transparent; border-bottom: 1px solid #D0D0D0; font-size: 19px; font-weight: normal; margin: 0 0 14px 0; padding: 14px 15px 10px 15px; } code { font-family: Consolas, Monaco, Courier New, Courier, monospace; font-size: 12px; background-color: #f9f9f9; border: 1px solid #D0D0D0; color: #002166; display: block; margin: 14px 0 14px 0; padding: 12px 10px 12px 10px; } #body { margin: 0 15px 0 15px; } p.footer { text-align: right; font-size: 11px; border-top: 1px solid #D0D0D0; line-height: 32px; padding: 0 10px 0 10px; margin: 20px 0 0 0; } #container { margin: 10px; border: 1px solid #D0D0D0; box-shadow: 0 0 8px #D0D0D0; } </style> </head> <body> <div id="container"> <h1>Welcome to CodeIgniter!</h1> <hr /> <form name="login" action="<?php echo site_url('login/check');?>" method="post"> <?php @$act=$_GET['act']; if($act=='F'){ echo "<font color='red'>"; echo 'Login False'; echo "</font>"; echo "<br />"; } ?> user = admin <br /> <input type="text" name="emp_username" > <br /> pass = admin <br /> <input type="password" name="emp_password" > <br /> <button type="submit"> Login </button> </form> </div> <p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds. <?php echo (ENVIRONMENT === 'development') ? 'CodeIgniter Version <strong>' . CI_VERSION . '</strong>' : '' ?></p> </div> </body> </html> |
view loinok.php if login pass
1 |
<?php echo $result;?> |