I just upload my website from localhost to hostinger with filezilla.
I already configure the database setting and all working well, but i get different result if i want login to the website. it give error "the username or password is wrong".
After that, I run the website in my localhost. Login with same username/ password and its working.
I dont know the error, i use same code between the local and hostinger
controller/login.php
<?php
class Login extends CI_Controller {
function __construct() {
parent::__construct();
session_start();
$this->load->model(array('mlogin'));
if ($this->session->userdata('email')) {
$this->load->view('header1');
}
elseif (!$this->session->userdata('email')) {
$this->load->view('header');
}
}
function index() {
$this->load->view('login');
}
function proses() {
$this->form_validation->set_rules('email', 'email', 'required|trim|xss_clean');
$this->form_validation->set_rules('password', 'password', 'required|trim|xss_clean');
if ($this->form_validation->run() == FALSE) {
$this->load->view('login');
} else {
$usr = $this->input->post('email');
$psw = $this->input->post('password');
$u = mysql_real_escape_string($usr);
$p = md5(mysql_real_escape_string($psw));
$cek = $this->mlogin->cek($u, $p);
if ($cek->num_rows() > 0) {
//login berhasil, buat session
foreach ($cek->result() as $qad) {
$sess_data['u_id'] = $qad->u_id;
$sess_data['nama'] = $qad->nama;
$sess_data['email'] = $qad->email;
$sess_data['role'] = $qad->role;
$this->session->set_userdata($sess_data);
}
redirect('home');
} else {
$this->session->set_flashdata('result_login', '<br>Username atau Password yang anda masukkan salah.');
redirect('login');
}
}
}
function logout() {
$this->session->sess_destroy();
redirect('login');
}}
model/mlogin.php
<?php
class Mlogin extends CI_Model {
private $table = "user";
function cek($email, $password) {
$this->db->where("email", $email);
$this->db->where("u_paswd", $password);
return $this->db->get("user");
}
function semua() {
return $this->db->get("user");
}
function cekKode($kode) {
$this->db->where("email", $kode);
return $this->db->get("user");
}
function cekId($kode) {
$this->db->where("u_id", $kode);
return $this->db->get("user");
}
function getLoginData($usr, $psw) {
$u = mysql_real_escape_string($usr);
$p = md5(mysql_real_escape_string($psw));
$q_cek_login = $this->db->get_where('users', array('email' => $u, 'password' => $p));
if (count($q_cek_login->result()) > 0) {
foreach ($q_cek_login->result() as $qck) {
foreach ($q_cek_login->result() as $qad) {
$sess_data['logged_in'] = 'vera';
$sess_data['u_id'] = $qad->u_id;
$sess_data['email'] = $qad->email;
$sess_data['nama'] = $qad->nama;
$sess_data['group'] = $qad->group;
$sess_data['rid'] = $qad->rid;
$this->session->set_userdata($sess_data);
}
redirect('main');
}
} else {
$this->session->set_flashdata('result_login', '<br>Username atau Password yang anda masukkan salah.');
header('location:' . base_url() . 'login');
}
}
function update($id, $info) {
$this->db->where("u_id", $id);
$this->db->update("user", $info);
}
function simpan($info) {
$this->db->insert("user", $info);
}
function hapus($kode) {
$this->db->where("u_id", $kode);
$this->db->delete("user");
}
}
view/login.php
<html>
<head>
<meta charset="UTF-8">
<title>Log in</title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<!-- Font Awesome Icons -->
<link href="<?php echo base_url('assets/css/font-awesome.min.css'); ?>" rel="stylesheet">
<!-- Theme style -->
<link href="<?php echo base_url('assets/css/AdminLTE.min.css'); ?>" rel="stylesheet">
<!-- iCheck -->
<link href="<?php echo base_url('assets/js/plugins/iCheck/square/blue.css'); ?>" rel="stylesheet">
</head>
<body>
<body class="login-page">
<div class="login-box">
<div class="login-logo">
<div class="login-box-body">
<h2>Login</h2>
<form action="<?php echo site_url('login/proses'); ?>" method="post">
<?php
if (validation_errors() || $this->session->flashdata('result_login')) {
?>
<div class="alert alert-error">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Warning!</strong>
<?php echo validation_errors(); ?>
<?php echo $this->session->flashdata('result_login'); ?>
</div>
<?php } ?>
<div class="form-group has-feedback">
<input type="email" name="email" class="form-control" placeholder="Username"/>
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" name="password" class="form-control" placeholder="Password"/>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div>
<button type="submit" class="btn btn-primary btn-block btn-flat">Masuk</button>
<br>
<h4>Daftar Anggota Baru</h4>
</div><!-- /.col -->
</div>
</form>
</div><!-- /.login-box-body -->
</div><!-- /.login-box -->
<!-- jQuery 2.1.3 -->
<script src="<?php echo base_url('assets/js/plugins/jQuery/jQuery-2.1.3.min.js'); ?>"></script>
<!-- Bootstrap 3.3.2 JS -->
<script src="<?php echo base_url('assets/js/bootstrap.min.js'); ?>"></script>
<!-- iCheck -->
<script src="<?php echo base_url('assets/js/plugins/iCheck/icheck.min.js'); ?>"></script>
<script>
$(function () {
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' // optional
});
});
</script>
<script>
$(function () {
$("#slider").responsiveSlides({
auto: true,
nav: true,
speed: 500,
namespace: "callbacks",
pager: true,
});
});
</script>
<!--footer-starts-->
<?php $this->load->view('footer') ?>
<!---->
</div>
</body>
</html>
localhost php version 5.6.11
hostinger php version 5.6.18
Hostinger sensitive with capitalization
change this code
$this->form_validation->set_rules('email', 'email', 'required|trim|xss_clean');
$this->form_validation->set_rules('password', 'password', 'required|trim|xss_clean');
with this
$this->form_validation->set_rules('email', 'Email', 'required|trim|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'required|trim|xss_clean');
and i think this code will give you 0 for $p
$p = md5(mysql_real_escape_string($psw));
just use this
$p = md5($psw);
Related
Hi I am encountering a strange error ,I have a small application having few pages for reports and entering logs ,the login authentication form is working perfectly fine on another host computer ,I have simply replicated the data to a new host computer ,the Login form gets refreshed after clicking on submit button ,I am not sure what is the reason behind I tried multiple ways to dig out the actual reason somehow I am failed here is my code data
Views/login.php
'''
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ITS</title>
<!-- CSS -->
<link rel="stylesheet" href="<?php echo base_url() ?>frontend/css?family=Roboto:400,100,300,500">
<link rel="stylesheet" href="<?php echo base_url() ?>frontend/css/bootstrap.min.css">
<link rel="stylesheet" href="<?php echo base_url() ?>frontend/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php echo base_url() ?>frontend/css/form-elements.css">
<link rel="stylesheet" href="<?php echo base_url() ?>frontend/css/style.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Favicon and touch icons -->
<link rel="shortcut icon" href="assets/ico/favicon.png">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
</head>
<body>
<!-- Top content -->
<div class="top-content">
<div class="inner-bg">
<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2 text">
<h1><strong>ITS</strong></h1>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3 form-box">
<div class="form-top">
<div class="form-top-left">
<h3>Login</h3>
<p>Enter your username and password to log on:</p>
</div>
<div class="form-top-right">
<i class="fa fa-lock"></i>
</div>
</div>
<div class="form-bottom">
<form action="<?php echo base_url('index.php/Login');?>" method="post" class="login-form">
<div class="form-group">
<label class="sr-only" for="form-username">Username</label>
<input type="text" name="username" placeholder="Username..." class="form-username form-control" id="form-username">
</div>
<div class="form-group">
<label class="sr-only" for="form-password">Password</label>
<input type="password" name="password" placeholder="Password..." class="form-password form-control" id="form-password">
</div>
<button type="submit" class="btn">Sign in!</button>
</form>
</div>
</div>
</div>
<div class="row">
</div>
</div>
</div>
</div>
<!-- Javascript -->
<script src="<?php echo base_url() ?>frontend/js/jquery-1.11.1.min.js"></script>
<script src="<?php echo base_url() ?>frontend/js/bootstrap.min.js"></script>
<script src="<?php echo base_url() ?>frontend/jquery.backstretch.min.js"></script>
<script src="<?php echo base_url() ?>frontend/scripts.js"></script>
<!--[if lt IE 10]>
<script src="assets/js/placeholder.js"></script>
<![endif]-->
</body>
Controller/Login.php
<?php
class Login extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->library('form_validation');
$this->load->helper('form');
$this->load->helper('url');
$this->load->model('main_db');
}
function index()
{
$this->form_validation->set_rules('username', 'username', 'required|trim|xss_clean|max_length[100]');
$this->form_validation->set_rules('password', 'password', 'required|trim|xss_clean|max_length[100]');
$this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('login');
}
else
{
$res=$this->main_db->get_table_where("users",array("username"=>set_value('username')));
if($res)
{
$form_data = array(
'username' => set_value('username'),
'password' => set_value('password'),
);
$res=$this->main_db->auth($form_data);
//print_r($res);
if ($res != "")
{
$uid = set_value('username');
$role = $res['role_id'];
$user_region= $res['region'];
$parameters['id']=$role;
$urole=$this->main_db->get_table_where('user_role',$parameters);
$con1 =$this->main_db->get_table_data('configuration');
$org_name = $con1[0]->Organization_Name;
$org_address = $con1[0]->Organization_Address;
$org_phone = $con1[0]->Organization_Phone;
$ur = $urole[0]->role;
$this->session->set_userdata('username', set_value('username'));
$this->session->set_userdata('user_role', $ur);
$this->session->set_userdata('user_region', $user_region);
$this->session->set_userdata('org_name', $org_name);
$this->session->set_userdata('org_address', $org_address);
$this->session->set_userdata('org_phone', $org_phone);
redirect('/mainpage/callregister');
}
else
{
$data["error"]="Password is incorrect.";
$this->load->view('login',$data);
}
}
else
{
$data["error"]="Username doesnot exist.";
$this->load->view('login',$data);
}
}
}
}
?>
Model/main_db.php
<?php
class Main_db extends CI_Model {
var $debug = 1;
var $user_region="";
var $urole ="";
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->load->database();
$this->load->library('custom_library');
$this->user_region =$this->session->userdata("user_region");
$this->urole =$this->session->userdata("user_role");
}
function Get_Row($qu,$parameters=array())
{
$dbquery = $this->db->query($qu, $parameters);
$ret = $dbquery->row_array();
return $ret;
}
///////////////////////////////////////////////
function auth($formdata)
{
$uid = $formdata['username'];
$pwd = $formdata['password'];
$qu="select * from users where username=? and password=?";
$parameters = array($uid, $pwd);
$ret2 = $this->Get_Row($qu,$parameters);
if (count($ret2) > 0)
{
$ret=$ret2;
}
else
{
$ret="";
}
return $ret;
}
////////////////////////////////////////////////////
function get_table_data($table)
{
$query = $this->db->get($table);
$res=$query->result();
return $res;
}
///////////////////////////////////////////////////////
function get_table_where($table,$parameters=array())
{
$query = $this->db->get_where($table,$parameters);
$res=$query->result();
return $res;
}
////////////////////////////////////////////////////////
////////////////////////////////////////////////////
function insert_table($table,$data)
{
return $this->db->insert($table,$data);
}
//////////////////////////////////////////////////////////////
function update_table_where($table,$data=array(),$parameters=array())
{
$this->db->where($parameters);
$this->db->update($table, $data);
return $this->db->affected_rows();
}
///////////////////////////////////////////////////////////////
function get_paginited_data($table, $start,$limit)
{
$query = $this->db->get($table, $limit, $start);
$res=$query->result();
return $res;
}
function get_paginited_where($table,$param=array(), $start,$limit)
{
$query = $this->db->get_where($table,$param, $limit, $start);
//echo $this->db->last_query();
$res=$query->result();
return $res;
}
function get_role_menus($role)
{
$query = "SELECT * FROM role_permissions a inner join modules b on a.module_id=b.module_id and a.role='$role'";
$query=$this->db->query($query);
$res=$query->result();
return $res;
}
function get_submodules($parent_id,$role)
{
$query = "SELECT * FROM submodules_permissions a inner join sub_modules b on a.module_id=b.module_id and a.role='$role' and a.parent_id='$parent_id' order by b.visible_name";
$query=$this->db->query($query);
$res=$query->result();
return $res;
}
function get_menu_details($id,$child)
{
if($child==0)
{
$table="modules";
}
else
{
$table="sub_modules";
}
$qu="Select * from $table where module_id='$id'";
$query=$this->db->query($qu);
$r=$query->result();
return $r[0];
}
function count_childs($parent_id)
{
$qu="select count(*) as total from sub_modules where parent_id='$parent_id'";
$query=$this->db->query($qu);
$r=$query->result();
return $r[0]->total;
}
function get_child_menus($parent_id)
{
$qu="Select * from sub_modules where parent_id='$parent_id'";
$query=$this->db->query($qu);
$r=$query->result();
return $r;
}
function check_menu_permissions($id,$role,$child)
{
if($child==0)
{
$table="role_permissions";
}
else
{
$table="submodules_permissions";
}
$qu="Select count(*) as total from $table where module_id='$id' and role='$role'";
$query=$this->db->query($qu);
$r=$query->result();
return $r;
}
function delete_user_modules($role)
{
$qu="delete from role_permissions where role='$role'";
$query=$this->db->query($qu);
return $query;
}
function delete_user_submodules($role)
{
$qu="delete from submodules_permissions where role='$role'";
$query=$this->db->query($qu);
return $query;
}
function add_module_permission($module_id,$role)
{
$res=$this->insert_table("role_permissions",array("role"=>$role,"module_id"=>$module_id));
return $res;
}
function add_submodule_permission($module_id,$role,$parent_id)
{
$res=$this->insert_table("submodules_permissions",array("role"=>$role,"module_id"=>$module_id,"parent_id"=>$parent_id));
return $res;
}
function debug_log($message)
{
$fp = fopen ("frontend/debug.log","a+");
$date = date("d-m-Y H:i:s");
$log = $date ."\t ".$message."\n";
fwrite($fp,$log);
fclose($fp);
///////////////////
if(file_exists("../frontend/debug.log"))
{
$fp3 = fopen ("../frontend/debug.log");
$date = date("d-m-Y H:i:s");
$log = $date ."\t ".$message."\n";
fwrite($fp3,$log);
fclose($fp3);
}
}
//////////////////////////////
function daily_report($dfrom,$dto)
{
#$query = "SELECT * from callregister where current_date >='$dfrom' and current_date <='$dto' ";
$query = "SELECT * from callregister where cdate >='$dfrom' and cdate <='$dto' ";
#echo $query;
$query=$this->db->query($query);
$res=$query->result();
return $res;
}
/////adeel function//////
///////////////////////////////////////////////////////////adeel////////////
function summary_rep($month,$year)
{
$query="SELECT cdate,COUNT(*) as total FROM callregister WHERE MONTH(cdate)='$month' AND YEAR(cdate)='$year' GROUP BY cdate ";
$query=$this->db->query($query);
$res=$query->result();
return $res;
}
/////////////call register pending tasks//////////////
function pending_report($dfrom,$dto)
{
#$query = "SELECT * from pending where current_date >='$dfrom' and current_date <='$dto' ";
$query = "SELECT * from pending where cdate >='$dfrom' and cdate <='$dto' ";
#echo $query;
$query=$this->db->query($query);
$res=$query->result();
return $res;
}
///////////////////////////////
}
?>
database.php
hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'callregister',
'dbdriver' => 'mysqli',
I am trying to make youtube clone website in php. I am stuck at a stage where i want to insert video that i am trying to upload into mysql database but it says error code 1. My project structure is as follows in below image
Screenshot of my website when i upload the entry as below
When click on upload button, i get the error as below image
Here is my upto date code that i have tried.
index.php File:
<?php require_once("includes/header.php"); ?>
<?php require_once("includes/footer.php"); ?>
header.php file:
<?php require_once("includes/config.php"); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>VideoTube</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="assets/js/commonActions.js"></script>
</head>
<body>
<div id="pageContainer">
<!-- Master Head Container -->
<div id="mastHeadContainer">
<!-- Hamburger Menu Button -->
<button class="navShowHide">
<img src="assets/images/icons/menu.png">
</button> <!--End of Hamburger Menu Button -->
<!-- Site Logo -->
<a class="logoContainer" href="index.php">
<img src="assets/images/icons/VideoTubeLogo.png" title="logo" alt="Site logo">
</a> <!-- End of Site Logo -->
<!-- Search Bar -->
<div class="searchBarContainer">
<form action="search.php" method="GET">
<input type="text" class="searchBar" name="term" placeholder="Search...">
<button class="searchButton">
<img src="assets/images/icons/search.png">
</button>
</form>
</div> <!-- End of Search Bar -->
<!-- Right Icons Area -->
<div class="rightIcons">
<a href="upload.php">
<img class="upload" src="assets/images/icons/upload.png">
</a>
<a href="#">
<img class="upload" src="assets/images/profilePictures/default.png">
</a>
</div> <!-- End of Right Icons Area -->
</div> <!-- End of Master Head Container -->
<div id="sideNavContainer" style="display:none;">
</div>
<div id="mainSectionContainer">
<div id="mainContentContainer">
footer.php file:
</div>
</div>
</div>
</body>
</html>
config.php file:
<?php
ob_start(); // turns on output buffering
date_default_timezone_set("Asia/Calcutta");
try {
$con = new PDO("mysql:dbname=VideoTube;host=localhost", "root", "");
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
}catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
?>
VideoDetailsFormProvider.php file:
<?php
class VideoDetailsFormProvider {
private $con;
public function __construct($con) {
$this->con = $con;
}
public function createUploadForm() {
$fileInput = $this->createFileInput();
$titleInput = $this->createTitleInput();
$descriptionInput = $this->createDescriptionInput();
$privacyInput = $this->createPrivacyInput();
$categoriesInput = $this->createCategoriesInput();
$uploadButton = $this->createUploadButton();
return "<form action='processing.php' method='POST' enctype='multipart/form-data'>
$fileInput
$titleInput
$descriptionInput
$privacyInput
$categoriesInput
$uploadButton
</form>";
}
private function createFileInput() {
return "<div class='form-group'>
<input type='file' class='form-control-file' id='exampleFormControlFile1' name='fileInput' required>
</div>";
}
private function createTitleInput() {
return "<div class='form-group'>
<input class='form-control' type='text' placeholder='Title' name='titleInput'>
</div>";
}
private function createDescriptionInput() {
return "<div class='form-group'>
<textarea class='form-control' placeholder='Description' name='descriptionInput' rows='3'></textarea>
</div>";
}
private function createPrivacyInput() {
return "<div class='form-group'>
<select class='form-control' name='privacyInput'>
<option value='0'>Private</option>
<option value='1'>Public</option>
</select>
</div>";
}
private function createCategoriesInput() {
$query = $this->con->prepare("SELECT * FROM categories");
$query->execute();
$html = "<div class='form-group'>
<select class='form-control' name='categoryInput'>";
while($row = $query->fetch(PDO::FETCH_ASSOC)) {
$id = $row["id"];
$name = $row["name"];
$html .= "<option value='$id'>$name</option>";
}
$html .= "</select>
</div>";
return $html;
}
private function createUploadButton() {
return "<button type='submit' class='btn btn-primary' name='uploadButton'>Upload</button>";
}
}
?>
VideoProcessor.php file:
<?php
class VideoProcessor {
private $con;
private $sizeLimit = 500000000;
private $allowedTypes = array("mp4", "flv", "webm", "mkv", "vob", "ogv", "ogg", "avi", "wmv", "mov", "mpeg", "mpg");
public function __construct($con) {
$this->con = $con;
}
public function upload($videoUploadData) {
$targetDir = "uploads/videos/";
$videoData = $videoUploadData->videoDataArray;
$tempFilePath = $targetDir . uniqid() . basename($videoData["name"]);
//uploads/videos/5aa3e9343c9ffdogs_playing.flv
$tempFilePath = str_replace(" ", "_", $tempFilePath);
$isValidData = $this->processData($videoData, $tempFilePath);
if(!$isValidData) {
return false;
}
if(move_uploaded_file($videoData["tmp_name"], $tempFilePath)) {
$finalFilePath = $targetDir . uniqid() . ".mp4";
if(!$this->insertVideoData($videoUploadData, $finalFilePath)) {
echo "Insert query failed";
return false;
}
}
}
private function processData($videoData, $filePath) {
$videoType = pathInfo($filePath, PATHINFO_EXTENSION);
if(!$this->isValidSize($videoData)) {
echo "File too large. Can't be more than " . $this->sizeLimit . " bytes";
return false;
}
else if(!$this->isValidType($videoType)) {
echo "Invalid file type";
return false;
}
else if($this->hasError($videoData)) {
echo "Error code: " . $videoData["error"];
return false;
}
return true;
}
private function isValidSize($data) {
return $data["size"] <= $this->sizeLimit;
}
private function isValidType($type) {
$lowercased = strtolower($type);
return in_array($lowercased, $this->allowedTypes);
}
private function hasError($data) {
return $data["error"] != 0;
}
private function insertVideoData($uploadData, $filePath) {
$query = $this->con->prepare("INSERT INTO videos(title, uploadedBy, description, privacy, category, filePath)
VALUES(:title, :uploadedBy, :description, :privacy, :category, :filePath)");
$query->bindParam(":title", $uploadData->title);
$query->bindParam(":uploadedBy", $uploadData->uploadedBy);
$query->bindParam(":description", $uploadData->description);
$query->bindParam(":privacy", $uploadData->privacy);
$query->bindParam(":category", $uploadData->category);
$query->bindParam(":filePath", $filePath);
return $query->execute();
}
}
?>
VideoUploadData.php File:
<?php
class VideoUploadData {
public $videoDataArray, $title, $description, $privacy, $category, $uploadedBy;
public function __construct($videoDataArray, $title, $description, $privacy, $category, $uploadedBy) {
$this->videoDataArray = $videoDataArray;
$this->title = $title;
$this->description = $description;
$this->privacy = $privacy;
$this->category = $category;
$this->uploadedBy = $uploadedBy;
}
}
?>
processing.php File:
<?php
require_once("includes/header.php");
require_once("includes/classes/VideoUploadData.php");
require_once("includes/classes/VideoProcessor.php");
if(!isset($_POST["uploadButton"])) {
echo "No file sent to page.";
exit();
}
// 1) create file upload data
$videoUploadData = new VideoUploadData(
$_FILES["fileInput"],
$_POST["titleInput"],
$_POST["descriptionInput"],
$_POST["privacyInput"],
$_POST["categoryInput"],
"REPLACE-THIS"
);
// 2) Process video data (upload)
$videoProcessor = new VideoProcessor($con);
$wasSuccessful = $videoProcessor->upload($videoUploadData);
// 3) Check if upload was successful
?>
upload.php File:
<?php
require_once("includes/header.php");
require_once("includes/classes/VideoDetailsFormProvider.php");
?>
<div class="column">
<?php
$formProvider = new VideoDetailsFormProvider($con);
echo $formProvider->createUploadForm();
?>
</div>
<?php require_once("includes/footer.php"); ?>
Per https://www.php.net/manual/en/features.file-upload.errors.php:
UPLOAD_ERR_INI_SIZE
Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
You should be able to increase upload_max_filesize in php.ini to resolve the issue.
This question already exists:
How do I make my php not send form data to mysql if it doesn't meet criteria?
Closed 4 years ago.
As stated in the above title, I am completely perplexed as to why my site doesn't insert the data into my database (and yes I've made all the necessary columns and stuff). It is probably related to the radio buttons and the "Preke" tag so if you see anything I've messed up on, it'd help me out a lot!
Hese is my code:
<!DOCTYPE HTML>
<?php
// define variables and set to empty values
$VarErr = $PavErr = $AdErr = $PreErr = $PkErr = $KiekErr = "";
$Vardas = $Pavarde = $Adresas = $Preke = $Pk = $Kiekis = "";
?>
<html class="no-js" lang="en">
<head>
<title>Dailės parduotuvė</title>
<meta charset="UTF-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/stilius.css">
</head>
<body class="content ">
<div class="container">
<nav class="navbar navbar-expand-lg navbar-dark ">
<a class="navbar-brand" href="index.html">Kauno dailė</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="Visos.html">Visos prekės</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Uzsakymas.php">Užsisakymas</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Kontaktai</a>
</li>
</ul>
</div>
</nav>
<div>
<div class="content sm-4 text-center">
<h2>Užsisakymo forma</h2>
<p><span class="error">* privalomi laukai</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<p class="text-center">Vardas</p><br>
<input type="text" name="Vardas" value="<?php echo $Vardas;?>">
<span class="error">* <?php echo $VarErr;?></span>
<p class="text-center">Pavarde</p><br>
<input type="text" name="Pavarde" value="<?php echo $Pavarde;?>">
<span class="error">* <?php echo $PavErr;?></span>
<p class="text-center">Adresas</p><br>
<input type="text" name="Adresas" value="<?php echo $Adresas;?>">
<span class="error">* <?php echo $AdErr;?></span><br>
Prekės rūšis:<br>
<input type="radio" name="Preke" value="Vienišas(-a)" checked>Dažai(5€)<br>
<input type="radio" name="Preke" value="Susituokęs(-usi)">Teptukas(2€)<br>
<input type="radio" name="Preke" value="Išsiskyręs(-usi)">Pieštukas(2€)<br>
<input type="radio" name="Preke" value="Našlys(-ė)">Ofiso įrankis(1€)<br>
<span class="error">* <?php echo $PreErr;?></span>
<br>
<p class="text-center">Prekės kodas</p><br>
<input type="number" name="Pk" value="<?php echo $Pk;?>">
<span class="error">* <?php echo $PkErr;?></span>
<p class="text-center">Kiekis</p><br>
<input type="number" name="Kiekis" value="<?php echo $Kiekis;?>">
<span class="error">* <?php echo $KiekErr;?></span>
<br>
<!-- Input For Add Values To Database-->
<input type="submit" name="insert" value="Užsisakyti">
</div>
</div>
<div class="content py-5">
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["Vardas"])) {
$VarErr = "Įveskite vardą";
} else {
$Vardas= test_input($_POST["Vardas"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$Vardas)) {
$VarErr = "Galima vesti tik su raidėmis";
}
}
if (empty($_POST["Pavarde"])) {
$PavErr = "Įveskite pavardę";
} else {
$Pavarde = test_input($_POST["Pavarde"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$Pavarde)) {
$PavErr = "Galima vesti tik su raidėmis";
}
}
if (empty($_POST["Adresas"])) {
$AdErr = "Įveskite adresą";
} else {
$Adresas= test_input($_POST["Adresas"]);
}
}
if (empty($_POST["Preke"])) {
$PreErr = "Pasirinkite prekės tipą";
} else {
$Preke = test_input($_POST["Preke"]);
}
if (empty($_POST["Pk"])) {
$Pk = "Įveskite prekės kodą";
} else {
$Pk = test_input($_POST["Pk"]);
}
if (empty($_POST["Kiekis"])) {
$KiekErr = "Įveskite kiekį";
} else {
$Kiekis = test_input($_POST["Kiekis"]);
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$host = "localhost";
$user = "root";
$password ="";
$database = "uzsakymas";
try{
$connect = mysqli_connect($host,$user,$password,$database);
}
catch(mysqli_sql_exception $ex){
echo 'database connection error';
}
//insert
if(isset($_POST['insert'])) {
$Vardas = $_POST['Vardas'];
$Pavarde = $_POST['Pavarde'];
$Adresas = $_POST['Adresas'];
$Preke = $_POST['Preke'];
$Pk = $_POST['Pk'];
$Kiekis = $_POST['Kiekis'];
$insert_query = "INSERT INTO uzsakymai (Vardas,Pavarde,Adresas,Preke,Pk,Kiekis,)VALUES('$Vardas','$Pavarde','$Adresas','$Preke','$Pk','$Kiekis')";
try {
$insert_result = mysqli_query($connect,$insert_query);
if($insert_result){
if(mysqli_affected_rows($connect) > 0)
{
echo 'Data Inserted';
}else{
echo'Data not Inserted';
}
}
} catch(Exception $ex) {
echo 'Error Insert'.$ex->getMessmessage();
}
}
?>
</div>
<div class = "footer py-5 bg-secondary">
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
Your problem is in 'input value' properties. You set it to empty variables. Remove value from input tag like this:
<p class="text-center">Vardas</p><br><input type="text" name="Vardas" placeholder="Vardas">
it should work. About your MySQL queries, they are vulnerable for SQL Injections attack. Use PDO to protect against SQL Injections.
You have already inserted values and if you want to use values="". Then, in your SQL, you should UPDATE and not INSERT. Also,as rpm192 stated above you should use parameterized queries, otherwise you will face SQL injections. Good Luck!
This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 6 years ago.
Hi so I keep running into this error and I was wondering how can I fix it! It is very important because this project is for a school degree.
This form basically will be used for uploading youtube embed codes and call them in another page!
I am using strip_tags but it seems it will not work because it says undefined variables both $video_title and $video_code.So this is what the page looks like when i first open it:http://imgur.com/a/hTsW7
and this is when i click the submit button:
http://imgur.com/a/ToVV8
I know its a duplicate but I have tried so many options found here but none seems to work!I tried isset(); , I tried $_POST[] but no better results.I also tried to change the whole registration and login form but still nothing!
What are those errors and why
I am new into PHP so sorry for the bad explanation!
This is the home_teacher_upload.php :
<?php
require_once("session.php");
require_once("class.user.php");
$teacher = new USER();
if(isset($_POST['btn-submit']))
{
$video_title = strip_tags($_GET['video_title']);
$video_code = strip_tags($_GET['video_code']);
if ($video_title == "") {
$error[]="Duhet të vendosni titullin fillimisht!";
}
echo "<h3>Videoja u ngarkua me sukses!</h3>";
}
try {
$stmt = $teacher->runQuery("SELECT video_title, video_code FROM videos WHERE video_title=:video_title OR video_code=:video_code");
$stmt->execute(array(':video_title'=>$video_title, ':video_code'=>$video_code));
$row=$stmt->fetch(PDO::FETCH_ASSOC);
if($row['video_title']==$video_title) {
echo "<h3>Ky titull është jo valid!</h3>";
}
else if($row['video_code']==$video_code) {
$error[] = "Kjo video aktualisht është e ngarkuar";
}
else
{
$teacher->submit_video($video_title,$video_code);
}
}
catch (PDOException $e) {
echo $e->getMessage();
}
?>
<link href="img/favicon.png" rel="shortcut icon" />
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Cookie">
<link rel="stylesheet" href="css/user.css">
<link rel="stylesheet" href="bootstrap/fonts/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Fjalla+One" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Patua+One" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Bree+Serif" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Anton" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Hammersmith+One" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="jquery-1.11.3-jquery.min.js"></script>
<link rel="stylesheet" href="style.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/user.css">
<title>Ngarkoni video!</title>
</head>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" style="
font-family: Bree Serif;">IB-Learning </a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-user"></span> <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><span class="glyphicon glyphicon-user"></span> Profili</li>
<li><span class="glyphicon glyphicon-log-out"></span> Dilni</li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="clearfix"></div>
<div class="container-fluid" style="margin-top:80px;">
</div>
<div class="wanna" style="text-align: center;">
<h3 style="font-family: Hammersmith One;">Ngarkoni një video</h3></div>
<div class="form" style="text-align: center; margin-left: 431px;
padding-top: 13px;">
<form class="submit_video" method="POST" style="text-align: center;">
<div class="form-group" style="font-family: Bree Serif; width: 28%;">
<input type="text" class="form-control" name="video_title" required placeholder="Titulli i videos" style="text-align: center;"/>
</div>
<div class="form-group" style="font-family: Bree Serif;margin-left: -37px;">
<textarea name="video_code" class="form-control" style="width: 240px; margin: 0px 337px 0px 0px; height: 165px; text-align: center;" form="code" placeholder="Embed code i videos" required="true"></textarea>
</div>
<div class="button_form-group">
<button type="submit" class="btn btn-primary" style="margin-right: 415px;font-family: Bree Serif;" name="btn-submit">
Submit
</button>
</div>
</form>
</div>
<?php include('footer.php');?>
<script src="bootstrap/js/bootstrap.min.js"></script>
<style type="text/css">
h3{
font-family: Bree Serif;
text-align: center;
padding-left: 20px;
}
</style>
</body>
</html>
This is session.php :
<?php
session_start();
require_once 'class.user.php';
$session = new USER();
// if user session is not active(not loggedin) this page will help 'home.php and profile.php' to redirect to login page
// put this file within secured pages that users (users can't access without login)
if(!$session->is_loggedin())
{
// session no set redirects to login page
$session->redirect('login.php');
}
and this is class.user.php :
<?php
require_once('dbconfig.php');
class USER
{
private $conn;
public function __construct()
{
$database = new Database();
$db = $database->dbConnection();
$this->conn = $db;
}
public function runQuery($sql)
{
$stmt = $this->conn->prepare($sql);
return $stmt;
}
public function register($uname,$umail,$upass)
{
try
{
$new_password = password_hash($upass, PASSWORD_DEFAULT);
$stmt = $this->conn->prepare("INSERT INTO tik_students(user_name,user_email,user_pass)
VALUES(:uname, :umail, :upass)");
$stmt->bindparam(":uname", $uname);
$stmt->bindparam(":umail", $umail);
$stmt->bindparam(":upass", $new_password);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function register_teacher($t_uname,$t_umail,$t_upass)
{
try
{
$new_password = password_hash($upass, PASSWORD_DEFAULT);
$stmt = $this->conn->prepare("INSERT INTO tik_teachers(user_name,user_email,user_pass)
VALUES(:uname, :umail, :upass)");
$stmt->bindparam(":uname", $t_uname);
$stmt->bindparam(":umail", $t_umail);
$stmt->bindparam(":upass", $t_new_password);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function doLogin($uname,$umail,$upass)
{
try
{
$stmt = $this->conn->prepare("SELECT user_id, user_name, user_email, user_pass FROM tik_students WHERE user_name=:uname OR user_email=:umail ");
$stmt->execute(array(':uname'=>$uname, ':umail'=>$umail));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount() == 1)
{
if(password_verify($upass, $userRow['user_pass']))
{
$_SESSION['user_session'] = $userRow['user_id'];
return true;
}
else
{
return false;
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function doLogin_teacher($t_uname,$t_umail,$t_upass)
{
try
{
$stmt = $this->conn->prepare("SELECT user_id, user_name, user_email, user_pass FROM tik_teachers WHERE user_name=:uname OR user_email=:umail ");
$stmt->execute(array(':uname'=>$t_uname, ':umail'=>$t_umail));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount() == 1)
{
if(password_verify($t_upass, $userRow['user_pass']))
{
$_SESSION['user_session'] = $userRow['user_id'];
return true;
}
else
{
return false;
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function submit_video($video_title,$video_code)
{
try
{
$stmt = $this->conn->prepare("INSERT INTO videos(video_title, video_code)
VALUES(:video_title, :video_code)");
$stmt->bindparam(":video_title", $video_title);
$stmt->bindparam(":video_code", $video_code);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function is_t_loggedin()
{
if(isset($_SESSION['user_session']))
{
return true;
}
}
public function is_loggedin()
{
if(isset($_SESSION['user_session']))
{
return true;
}
}
public function redirect($url)
{
header("Location: $url");
}
public function doLogout()
{
session_destroy();
unset($_SESSION['user_session']);
return true;
}
}
?>
Help would be appreciated
Notice: Undefined index / Undefined offset
This notice appears when you (or PHP) try to access an undefined index
of an array.
You need to check like below first
if(isset($_GET['video_code'])){
}
So in your case
$video_code = isset($_GET['video_code']) ? strip_tags($_GET['video_code']): ' ';
Check if the index exists before you access it.
For this you can use
isset()
or
array_key_exists():
//isset()
$video_code = isset($_GET['video_code']) ? strip_tags($_GET['video_code']): '';
// OR
//array_key_exists()
$video_code = array_key_exists('video_code',$_GET) ? strip_tags($_GET['video_code']): '';
i' newbie code iginiter 3 with mysql database, and xampp v3.2 .
Error 'The address wasn't understood' when i click login button.
help me ...
this config
<code>`enter code here`
$config['base_url'] = 'localhost:8087/hris/';
$config['index_page'] = 'login.php';
</code>
and my route.php
<code>
$route['default_controller'] = 'user_authentication';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
</code>
how to fix this error....
user_authentication.php
Class User_Authentication extends CI_Controller
{
//session_start(); //we need to start session in order to access it through CI
public function __construct()
{
parent::__construct();
// Load form helper library
$this->load->helper('form');
// Load form validation library
$this->load->library('form_validation');
// Load session library
$this->load->library('session');
// Load database
$this->load->model('login_database');
}
// Show login page
public function index()
{
$this->load->view('login');
}
// Show registration page
public function user_registration_show()
{
$this->load->view('registration_form');
}
// Validate and store registration data in database
public function new_user_registration()
{
// Check validation for user input in SignUp form
$this->form_validation->set_rules('username', 'Username','trim|required|xss_clean');
$this->form_validation->set_rules('email_value', 'Email', 'trim|required|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('registration_form');
} else
{
$data = array(
'user_name' => $this->input->post('UserID'),
'user_email' => $this->input->post('email_value'),
'user_password' => $this->input->post('password')
);
$result = $this->login_database->registration_insert($data);
if ($result == TRUE)
{
$data['message_display'] = 'Registration Successfully !';
$this->load->view('login_form', $data);
} else {
$data['message_display'] = 'Username already exist!';
$this->load->view('registration_form', $data);
}
}
}
// Check for user login process
public function user_login_process()
{
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
if ($this->form_validation->run() == FALSE)
{
if(isset($this->session->userdata['logged_in']))
{
$this->load->view('admin_page');
}else{
$this->load->view('login_form');
}
} else {
$data = array(
'username' => $this->input->post('username'),
'password' => $this->input->post('password')
);
$result = $this->login_database->login($data);
if ($result == TRUE)
{
$username = $this->input->post('username');
$result = $this->login_database->read_user_information($username);
if ($result != false)
{
$session_data = array(
'username' => $result[0]->user_name,
'email' => $result[0]->user_email,
);
// Add user data in session
$this->session->set_userdata('logged_in', $session_data);
$this->load->view('admin_page');
}
} else {
$data = array(
'error_message' => 'Invalid Username or Password'
);
$this->load->view('login_form', $data);
}
}
}
// Logout from admin page
public function logout()
{
// Removing session data
$sess_array = array(
'username' => ''
);
$this->session->unset_userdata('logged_in', $sess_array);
$data['message_display'] = 'Successfully Logout';
$this->load->view('login_form', $data);
}
}
?>
this models login_database.php
Class Login_Database extends CI_Model
{
// Insert registration data in database
public function registration_insert($data)
{
// Query to check whether username already exist or not
$condition = "user_name =" . "'" . $data['user_name'] . "'";
$this->db->select('*');
$this->db->from('user_login');
$this->db->where($condition);
$this->db->limit(1);
$query = $this->db->get();
if ($query->num_rows() == 0)
{
// Query to insert data in database
$this->db->insert('user_login', $data);
if ($this->db->affected_rows() > 0)
{
return true;
}
} else {
return false;
}
}
// Read data using username and password
public function login($data)
{
$condition = "user_name =" . "'" . $data['username'] . "' AND " . "user_password =" . "'" . $data['password'] . "'";
$this->db->select('*');
$this->db->from('user_login');
$this->db->where($condition);
$this->db->limit(1);
$query = $this->db->get();
if ($query->num_rows() == 1) {
return true;
} else {
return false;
}
}
// Read data from database to show data in admin page
public function read_user_information($username) {
$condition = "user_name =" . "'" . $username . "'";
$this->db->select('*');
$this->db->from('user_login');
$this->db->where($condition);
$this->db->limit(1);
$query = $this->db->get();
if ($query->num_rows() == 1) {
return $query->result();
} else {
return false;
}
}
}
this view ( login.php )
$this->load->helper('form');
if (isset($this->session->userdata['logged_in'])) {
header("location: http://localhost/login/index.php/user_authentication/user_login_process");
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Global stylesheets -->
<link href="https://fonts.googleapis.com/css?family=Roboto:400,300,100,500,700,900" rel="stylesheet" type="text/css">
<link href="assets/css/icons/icomoon/styles.css" rel="stylesheet" type="text/css">
<link href="assets/css/minified/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="assets/css/minified/core.min.css" rel="stylesheet" type="text/css">
<link href="assets/css/minified/components.min.css" rel="stylesheet" type="text/css">
<link href="assets/css/minified/colors.min.css" rel="stylesheet" type="text/css">
<!-- /global stylesheets -->
<!-- Core JS files -->
<script type="text/javascript" src="assets/js/plugins/loaders/pace.min.js"></script>
<script type="text/javascript" src="assets/js/core/libraries/jquery.min.js"></script>
<script type="text/javascript" src="assets/js/core/libraries/bootstrap.min.js"></script>
<script type="text/javascript" src="assets/js/plugins/loaders/blockui.min.js"></script>
<!-- /core JS files -->
<!-- Theme JS files -->
<script type="text/javascript" src="assets/js/plugins/forms/styling/uniform.min.js"></script>
<script type="text/javascript" src="assets/js/core/app.js"></script>
<script type="text/javascript" src="assets/js/pages/login.js"></script>
<!-- /theme JS files -->
</head>
<body>
<!-- Main navbar -->
<div class="navbar navbar-inverse">
<div class="navbar-header">
<a class="navbar-brand" href="index.html"><img src="assets/images/logo_light.png" alt=""></a>
<ul class="nav navbar-nav pull-right visible-xs-block">
<li><a data-toggle="collapse" data-target="#navbar-mobile"><i class="icon-tree5"></i></a></li>
</ul>
</div>
</div>
<!-- /main navbar -->
<!-- Page container -->
<div class="page-container login-container">
<!-- Page content -->
<div class="page-content">
<!-- Main content -->
<div class="content-wrapper">
<!-- Content area -->
<div class="content">
<?php
echo form_open('user_authentication/user_login_process');
?>
<!-- Advanced login -->
<form action="" method="post">
<div class="panel panel-body login-form">
<div class="text-center">
<div class="icon-object border-slate-300 text-slate-300"><i class="icon-reading"></i></div>
<h5 class="content-group">Login to your account <small class="display-block">Your credentials</small></h5>
</div>
<div class="form-group has-feedback has-feedback-left">
<input type="text" class="form-control" placeholder="Username" name="userid" id="userid" required>
<div class="form-control-feedback">
<i class="icon-user text-muted"></i>
</div>
</div>
<div class="form-group has-feedback has-feedback-left">
<input type="text" class="form-control" placeholder="Password" name="pass" id="pass" required>
<div class="form-control-feedback">
<i class="icon-lock2 text-muted"></i>
</div>
</div>
<div class="form-group login-options">
<div class="row">
<div class="col-sm-6">
<label class="checkbox-inline">
<input type="checkbox" class="styled" checked="checked">
Remember
</label>
</div>
<div class="col-sm-6 text-right">
Forgot password?
</div>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn bg-blue btn-block">Login <i class="icon-arrow-right14 position-right"></i></button>
</div>
<?php echo form_close(); ?>
<div class="content-divider text-muted form-group"><span>Don't have an account?</span></div>
Sign up
</div>
</form>
<!-- /advanced login -->
</div>
<!-- /content area -->
</div>
<!-- /main content -->
</div>
<!-- /page content -->
</div>
<!-- /page container -->
</body>
</html>
</pre></code>
try to change your form open in to this
<?php
echo form_open(base_url('User_Authentication/user_login_process'));
?>
For anyone who face the problem of The address wasn't understood when clicking a link for example, just make sure to add http:// to the $config['base_url'] value, in the case of the question above, you should replace :
$config['base_url'] = 'localhost:8087/hris/';
by
$config['base_url'] = 'http://localhost:8087/hris/';
Hope this help :)