我是创建网站并尝试上传的新手 但是当我上传它时,它只是打开索引页面而不会登录
控制器
class Login extends CI_Controller {
// Index login
public function index() {
// Fungsi Login
$valid = $this->form_validation;
$nisn = $this->input->post('nisn');
$tgllahir = $this->input->post('tgllahir');
$valid->set_rules('nisn','nisn','required');
$valid->set_rules('tgllahir','tgllahir','required');
if($valid->run()) {
$this->simple_login->login($nisn,$tgllahir, base_url('cetak'), base_url('login'));
}
// End fungsi login
$data = array( 'title' => 'Cetak Kelulusan');
$this->load->view('login_view',$data);
}
// Logout di sini
public function logout() {
$this->simple_login->logout();
}
}
查看
<?php
defined('BASEPATH') OR exit('No direct script access allowed');?>
<html>
<head>
<meta charset="utf-8">
<link href="<?php echo base_url() ?>assets/images/logo-javawebmeia.png" rel="shortcut icon">
<title><?php echo $title ?></title>
<link href="<?php echo base_url() ?>assets/css/style.css" rel="stylesheet">
</head>
<body>
<section class="login">
<h1>Cek Kelulusan Siswa</h1>
<form action="<?php echo base_url('login') ?>" method="post">
<p>
<label for="nisn">NISN</label>
<input type="text" name="nisn" id="nisn" placeholder="Masukkan NISN">
</p>
<p>
<label for="tgllahir">Tanggal Lahir</label>
<input type="text" name="tgllahir" id="tgllahir" placeholder="Contoh 02/05/1997">
</p>
<p>
<input type="submit" name="submit" id="submit" value="CEK" class="full">
</p>
</form>
<footer>Newbie</footer>
</section>
</body>
</html>
和simpel_login库
class Simple_login {
// SET SUPER GLOBAL
var $CI = NULL;
public function __construct() {
$this->CI =& get_instance();
}
// Fungsi login
public function login($nisn, $tgllahir) {
$query = $this->CI->db->get_where('siswa',array('nisn'=>$nisn,'tgllahir' => $tgllahir));
if($query->num_rows() == 1) {
$row = $this->CI->db->query('SELECT * FROM siswa where nisn = "'.$nisn.'"');
$admin = $row->row();
$nama = $admin->nama;
$nopes = $admin->nopes;
$nourut = $admin->nourut;
$kelas = $admin->kelas;
$noinduk= $admin->noinduk;
$this->CI->session->set_userdata('nisn', $nisn);
$this->CI->session->set_userdata('tgllahir', $tgllahir);
$this->CI->session->set_userdata('nama', $nama);
$this->CI->session->set_userdata('nopes', $nopes);
$this->CI->session->set_userdata('nourut', $nourut);
$this->CI->session->set_userdata('kelas', $kelas);
$this->CI->session->set_userdata('noinduk', $noinduk);
redirect(base_url('cetak'));
}else{
$this->CI->session->set_flashdata('sukses','Maaf NISN / Tanggal Lahir salah');
redirect(base_url('login'));
}
return false;
}
// Proteksi halaman
public function cek_login() {
if($this->CI->session->userdata('nisn') == '') {
$this->CI->session->set_flashdata('sukses','Anda belum login');
redirect(base_url('login'));
}
}
// Fungsi logout
public function logout() {
$this->CI->session->unset_userdata('nisn');
$this->CI->session->unset_userdata('nama');
$this->CI->session->unset_userdata('id');
$this->CI->session->set_flashdata('sukses','Anda berhasil logout');
redirect(base_url('login'));
}
}
不知何故,我试图登录后显示内部服务器错误