i have run script many times on local server , there no problem. when uploaded them on web server faced undefined errors. confused.
what problem??
database tables defined.
php version on local: 5.3.5, on web server: 5.3.26
i these errors:
php error encountered severity: notice message: undefined index: username filename: models/user.php line number: 7 php error encountered severity: notice message: undefined index: password filename: models/user.php line number: 8 php error encountered severity: warning message: cannot modify header information - headers sent (output started @ /home/caspian/domains/caspiansang.ir/public_html/system/core/exceptions.php:185) filename: views/login.php <p>line number: 1
controller/verifylogin.php:
<?php if ( ! defined('basepath')) exit('no direct script access allowed'); class verifylogin extends ci_controller { function __construct() { parent::__construct(); $this->load->model('user','',true); } function index() { $result = $this->user->validate(); if(! $result){ $data['msg'] = 'اطلاعات وارد شده اشتباه است!'; $this->load->view('login',$data); }else{ redirect('admin'); } } }
models/user.php
<?php class user extends ci_model { public function validate(){ $username = $_post['username']; $password = $_post['password']; // prep query $this->db->where('username', $username); $this->db->where('password', md5($password)); // run query $query = $this->db->get('admin'); // let's check if there results if($query->num_rows() == 1) { // if there user, create session data $row = $query->row(); $data = array( 'userid' => $row->userid, 'fname' => $row->fname, 'lname' => $row->lname, 'username' => $row->username, 'validated' => true ); $this->session->set_userdata($data); return true; } return false; } }
views/login.php:
<?php echo form_open('verifylogin'); ?> <br> <div style="font-color:black; padding-bottom:10px;"> <?php if(! empty($msg)) echo $msg;?></div> < label for="username">نام کاربری</label> <input type="text" size="20" id="username" name="username"/> <br/> <label for="password">رمز عبور</label> <input type="password" size="20" id="passowrd" name="password"/> <br/>
you have display_errors turned off on 1 server , on on other. issues still occur on both servers, don't told them on one.
the issue accessing variables or parts of arrays not defined before try use them.
Comments
Post a Comment