HTML form, link error - php

I have a very weird problem.
I'm coding login system and i have two buttons in form; one is for submitting and second is link and is used to send user to register page.
My problem is that when i click that link form is submitted instead of redirection.
Here is link to page:
http://takeaprize.pl/login.php
And page code:
<?php
include_once 'secure/core.php';
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $settings->getSiteTitle(); ?> - Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8" />
<meta name="description" content="<?php echo $settings->getMETAdescription(); ?>" />
<meta name="keywords" content="<?php echo $settings->getMETAkeywords(); ?>" />
<link rel="icon" type="image/ico" href="assets/images/favicon.ico" />
<!-- Bootstrap -->
<link href="assets/css/vendor/bootstrap/bootstrap.min.css" rel="stylesheet">
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link href="assets/css/minimal.css" rel="stylesheet">
<link rel="stylesheet" href="assets/js/vendor/jgrowl/css/jquery.jgrowl.min.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.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body class="bg-1">
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Make page fluid -->
<div class="row">
<!-- Page content -->
<div id="content" class="col-md-12 full-page login">
<div class="inside-block">
<img src="assets/images/logo-big.png" alt class="logo">
<h1><strong>Welcome</strong> Guest</h1>
<h5><?php echo $settings->getSiteTitle(); ?></h5>
<form id="login_form" class="form-signin" action="">
<section>
<div class="input-group">
<input type="text" class="form-control" name="username" placeholder="Username">
<div class="input-group-addon"><i class="fa fa-user"></i></div>
</div>
<div class="input-group">
<input type="password" class="form-control" name="password" placeholder="Password">
<div class="input-group-addon"><i class="fa fa-key"></i></div>
</div>
</section>
<section class="controls">
Forgot password?
</section>
<section class="log-in">
<button class="btn btn-greensea"><i class="fa fa-lock"></i> Log In</button>
<span>or</span>
<button class="btn btn-slategray"><i class="fa fa-sign-out"></i> Create an account</button>
</section>
</form>
</div>
</div>
<!-- /Page content -->
</div>
</div>
<!-- Wrap all page content end -->
</body>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery.js"></script>
<script src="assets/js/vendor/jgrowl/jquery.jgrowl.min.js"></script>
</html>
Thanks in advance for any help

Related

Login Page not loading code from file PHP/codeigniter/Bootstrap

I'm building a review site with code igniter in which you're able to login and add reviews. I've made a navigation bar with the Home and Login navs. I've created a login file and linked it to the navigation bar however once I click on login page there's a blank page and when i inspect the code there's no code within the body even though there's clear code in the file.
<html>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title> Login </title>
<!-- CSS -->
<link rel ="stylesheet" href="<?php echo base_url();?>application/css/homestyle.css">
<link rel="stylesheet" href="<?php echo base_url();?>application/css/bootstrap.min.css">
<!-- These classes only work if you attach Bootstrap. -->
<!-- Navigation Bar -->
<nav class="navbar navbar-expand-lg navbar-white bg-grey">
<h2 > GAMES REVIEW </h2>
<!-- Home -->
<a class="nav-link" href="<?php echo base_url();?>index.php">Home</a>
<!-- Login -->
<a class="nav-link" href="<?php echo base_url();?>application/views/login.php">Login</a>
</nav>
</head>
<body>
<!-- Login Form -->
<div class="login col-md-4 mx auto text-center" id="login">
<h1> Login </h1>
<form method="post" >
<div class="form-group">
<input type="text" name="username" placeholder="Username" class="form-control">
</div>
<div class="form-group">
<input type="password" name="password" placeholder="Password" class="form-control">
</div>
<div class="form-group">
<input type="submit" name="submit" value="login" class="btn btn-primary">
</div>
</form>
</div>
</body>
<!-- Load in the required scripts -->
</html>
href="echo base_url() application/css/homestyle.css"
tries to open document like this http://localhost/sitename/application/css.......
but it's not supposed to parsed with any controller.
i suggest you to use CDN instead.
you ca also use FCPATH const to address to your file like this
(FCPATH.'application/folder/file');

install codeigniter on sub domain, going to error when put controller on subfolder

I've installed my codeigniter on my subdomain: http://mt.domain.com and i've setup $config['base_url'] = 'http://mt.domain.com'.
I've user panel and admin panel, which is user panel controller already put on:
application/controllers/User.php, and this user panel work 100%.
But there is error for admin panel and login panel, which are already put on subfolder:
application/controllers/staff/Login.php
screenshoot:
error login
so the problem is occurred, when i put controller on sub folder, example: mt.domain.com/subfolder/admin
How to solve this problem? thanks
this is my controller Login.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Login extends CI_Controller{
function __construct(){
parent:: __construct();
$this->load->model('m_admin');
$this->load->helper('captcha');
$this->load->library('encryption');
}
function index(){
$this->load->view('admin/login/v_login');
}
and this is my view's file on views/admin/login/v_login.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Login - Bootstrap Admin Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link href="<?php echo base_url('assets/admin/css/bootstrap.min.css');?>" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url('assets/admin/css/bootstrap-responsive.min.css');?>" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url('assets/admin/css/font-awesome.css');?>" rel="stylesheet">
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600" rel="stylesheet">
<link href="<?php echo base_url('assets/admin/css/style.css" rel="stylesheet');?>" type="text/css">
<link href="<?php echo base_url('assets/admin/css/pages/signin.css');?>" rel="stylesheet" type="text/css">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" >
Login Admin MBill V.1.0
</a>
<div class="nav-collapse">
<ul class="nav pull-right">
<li class="">
<a href="https://mt.adrihost.com/" class="">
<i class="icon-chevron-left"></i>
Back to Homepage
</a>
</li>
</ul>
</div><!--/.nav-collapse -->
</div> <!-- /container -->
</div> <!-- /navbar-inner -->
</div> <!-- /navbar -->
<div class="account-container">
<div class="content clearfix">
<form action="<?php echo base_url('staff/login/aksi_login');?>" method="post">
<h1>Admin Login</h1>
<div class="login-fields">
<p>Please provide your details</p>
<div class="field">
<label for="username">Username</label>
<input type="text" id="username" name="username" value="" placeholder="Username" class="login username-field" />
</div> <!-- /field -->
<div class="field">
<label for="password">Password:</label>
<input type="password" id="password" name="password" value="" placeholder="Password" class="login password-field"/>
</div> <!-- /password -->
</div> <!-- /login-fields -->
<div class="login-actions">
<span class="login-checkbox">
<input id="Field" name="Field" type="checkbox" class="field login-checkbox" value="First Choice" tabindex="4" />
<label class="choice" for="Field">Keep me signed in</label>
</span>
<input type="submit" class="button btn btn-success btn-large" value="Sign In">
</div> <!-- .actions -->
</form>
</div> <!-- /content -->
</div> <!-- /account-container -->
<div class="login-extra">
Reset Password
</div> <!-- /login-extra -->
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/signin.js"></script>
</body>
</html>
You should use / to find the base directory in all assets
replace 'assets'/... to '/assets/...'
Example
Old :
<link href="<?php echo base_url('assets/admin/css/bootstrap.min.css');?>" rel="stylesheet" type="text/css" />
New :
<link href="<?php echo base_url('/assets/admin/css/bootstrap.min.css');?>" rel="stylesheet" type="text/css" />
And also put your assets folder on the root directory
Change all and you are done I think
problem solved.
the problem is on css file, which is need to be properly installed an assets folder on root. So i decided to put all css files on root. and then problem is solved.
thanks very much.

cakePHP3 - pure html login page

i'm using cakePHP3 with AdminLTE theme, i want my login page rendered with pure html from .ctp with no additional theme view generated by controller, is there a way to accomplish that? i've already tried $this->viewBuilder()->layout(false) in my action function, but it didn't work
Create a new layout to be used for the login page, let's call the layout 'loginLayout'. Below is a sample code based on maiconpinto adminlte plugin. If you are not using the plugin, make sure you indicate the right path for your CSS and script files.
<?php use Cake\Core\Configure; ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?php echo Configure::read('Theme.title'); ?></title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.5 -->
<?php echo $this->Html->css('AdminLTE./bootstrap/css/bootstrap.min'); ?>
<!-- iCheck -->
<?php echo $this->Html->css('AdminLTE./plugins/iCheck/all.css'); ?>
<!-- Font Awesome -->
<link rel="stylesheet" href='https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'>
<!-- Ionicons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
<!-- Theme style -->
<?php echo $this->Html->css('AdminLTE.AdminLTE.min'); ?>
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<?php echo $this->Html->css('AdminLTE.skins/skin-'. Configure::read('Theme.skin') .'.min'); ?>
<?php echo $this->fetch('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/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body class="hold-transition login-page">
<?php echo $this->Flash->render(); ?>
<?php echo $this->Flash->render('auth'); ?>
<?php echo $this->fetch('content'); ?>
<!-- jQuery -->
<?php echo $this->Html->script('https://code.jquery.com/jquery-3.2.1.min.js'); ?>
<!-- Bootstrap 3.3.5 -->
<?php echo $this->Html->script('AdminLTE./bootstrap/js/bootstrap.min'); ?>
<!-- iCheck -->
<?php echo $this->Html->script('AdminLTE./plugins/iCheck/icheck.min.js'); ?>
<!-- AdminLTE App -->
<?php echo $this->Html->script('AdminLTE./js/app.min'); ?>
<!-- AdminLTE for demo purposes -->
<?php echo $this->fetch('script'); ?>
<?php echo $this->fetch('scriptBottom'); ?>
<script>
$(function () {
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' // optional
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$(".navbar .menu").slimscroll({
height: "200px",
alwaysVisible: false,
size: "3px"
}).css("width", "100%");
var a = $('a[href="<?php echo $this->request->webroot . $this->request->url ?>"]');
if (!a.parent().hasClass('treeview') && !a.parent().parent().hasClass('pagination')) {
a.parent().addClass('active').parents('.treeview').addClass('active');
}
});
</script>
</body>
</html>
On your .ctp file, indicate the layout to be used
<?php
$this->layout = 'loginLayout';
?>
<div class="login-box">
<div class="login-logo">
<b>Admin</b>LTE
</div>
<!-- /.login-logo -->
<div class="login-box-body">
<p class="login-box-msg">Sign in to start your session</p>
<form action="../../index2.html" method="post">
<div class="form-group has-feedback">
<input type="email" class="form-control" placeholder="Email">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" placeholder="Password">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-8">
<div class="checkbox icheck">
<label>
<input type="checkbox"> Remember Me
</label>
</div>
</div>
<!-- /.col -->
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat">Sign In</button>
</div>
<!-- /.col -->
</div>
</form>
<div class="social-auth-links text-center">
<p>- OR -</p>
<a href="#" class="btn btn-block btn-social btn-facebook btn-flat"><i class="fa fa-facebook"></i> Sign in using
Facebook</a>
<a href="#" class="btn btn-block btn-social btn-google btn-flat"><i class="fa fa-google-plus"></i> Sign in using
Google+</a>
</div>
<!-- /.social-auth-links -->
I forgot my password<br>
Register a new membership
</div>
<!-- /.login-box-body -->
</div>
<!-- /.login-box -->

Configuring a login feature

This is my first time using a template. I'm a beginner.
Since I used adminlte template my codes stop working properly.
HTML Code:
<!DOCTYPE html>
enter code here<?php
session_start();
?>
<html>
<head>
<meta charset="UTF-8">
<title>Admin Panel | Log in</title>
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap 3.3.6 -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="font-awesome/font-awesome-2/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="ionicons/ionicons2/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="plugins/iCheck/square/blue.css">
<style type="text/css">
.img-bg-mine{
background: url('images/loginbg.jpg') no-repeat center center fixed; background-size: cover;
}
</style>
<!-- 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/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body class="hold-transition login-page img-bg-mine">
<div class="login-box">
<div class="login-logo">
<b>Student</b> Evaluation
</div>
<!-- /.login-logo -->
<div class="login-box-body">
<p class="login-box-msg">Sign in to start your session</p>
<form action="login.php" method="post">
<div class="form-group has-feedback">
<div class="input-group">
<input type="text" class="form-control" placeholder="Enter Your Username" name="login_username" id="login_username">
<span id="errorUsername"></span>
<span class="input-group-addon">
<i class="fa fa-user"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<div class="input-group">
<input type="password" class="form-control" placeholder="Enter Your Password" name="login_password" id="login_password">
<span id="errorPassword"></span>
<span class="input-group-addon">
<i class="fa fa-lock"></i>
</span>
</div>
<br>
<div class="row">
<div class="col-xs-12">
<button type="submit" class="btn bg-olive btn-flat pull-right btn-lg" name="login" id="login">Sign In</button>
</div>
</div>
</form>
</div>
<!-- /.login-box-body -->
</div>
<!-- jQuery 2.2.3 -->
<script src="plugins/JQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
PHP Code:
<?php
include 'dbcon.php';
?>
<?php
if(isset($_POST['login'])){
$username = mysqli_real_escape_string($conn,$_POST['login_username']);
$password = mysqli_real_escape_string($conn,$_POST['login_password']);
//select user from database
$select_user = "SELECT * from tb_admin where admin_user='$username' and admin_pass='$password'";
//run query
$login =mysqli_query($conn,$select_user);
$count =mysqli_num_rows($login);
$row= mysqli_fetch_array($login);
if ($count > 0){
session_start();
$_SESSION['id']=$row['admin_id'];
echo "<script>window.open('adminpanel.php','_self')</script>";// this part is not working it only shows the word window.open('adminpanel.php','_self') instead of showing the page adminpanel.php
}else
{
echo "<script>alert('Login failed..')</script>";// same here
echo "<script>window.open('index.php','_self')</script>";// same here
}
}
?>
It looks like my script in login.php is not working. It just shows the text nothing more.

Data hasn't saved thorough phpmyadmin

I want to save a form data through codeigniter framework in PhPMyadmin.But it's not working. it redirected to my form page automatically.
here is my View (form page's) code :
<!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">
<meta name="description" content="">
<meta name="author" content="">
<title><?php echo $title;?></title>
<!-- Bootstrap Core CSS -->
<link href="<?php echo base_url();?>bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- MetisMenu CSS -->
<link href="<?php echo base_url();?>bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="<?php echo base_url();?>dist/css/sb-admin-2.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="<?php echo base_url();?>bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/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]-->
</head>
<body>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Forms</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Basic Form Elements
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-6">
<form action"<?php echo base_url();?>super_admin/save_category" method="post" >
<div>
<?php
$message=$this->session->userdata('message');
if($message){
echo $message;
$this->session->unset_userdata('message');
}
?>
</div>
<div class="form-group">
<label>Text Input</label>
<input class="form-control" name="category_name">
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="form-group">
<label>Text area</label>
<textarea class="form-control" name="category_description" rows="3"></textarea>
</div>
<div class="form-group">
<label>Radio Buttons</label>
<div class="radio">
<label>
<input type="radio" name="publication_status" id="optionsRadios1" value="1" checked>Published
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="publication_status" id="optionsRadios2" value="0">Unpublished
</label>
</div>
</div>
<button type="submit" class="btn btn-default">Submit </button>
<button type="reset" class="btn btn-default">Reset </button>
</form>
</div>
</div>
<!-- /.row (nested) -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
</div>
</div>
<!-- /#wrapper -->
<!-- jQuery -->
<script src="<?php echo base_url();?>bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="<?php echo base_url();?>bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="<?php echo base_url();?>bower_components/metisMenu/dist/metisMenu.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="<?php echo base_url();?>dist/js/sb-admin-2.js"></script>
And here is my Controller code :
<?php
//session_start();
defined('BASEPATH') OR exit('No direct script access allowed');
/**
*
*/
class Super_Admin extends CI_Controller
{
public function __construct(){
parent::__construct();
$admin_id=$this->session->userdata('admin_id');
if($admin_id==NULL){
redirect('admin_login','refresh');
}
}
public function index()
{
$this->load->view('admin/admin_master');
}
public function add_category(){
$data=array();
//$data['admin_content']=$this->load->view('admin/add_category','',TRUE);
$data['title']='Add category';
$this->load->view('admin/add_category',$data);
}
public function save_category(){
$data=array();
$data['category_name']=$this->input->post('category_name',TRUE);
$data['category_description']=$this->input->post('category_description',TRUE);
$data['publication_status']=$this->input->post('publication_status',TRUE);
$this->super_admin_model->save_category_info($data);
$sdata=array();
$sdata['message']="Save Category information successfully";
$this->session->set_userdata($sdata);
redirect('super_admin/add_category');
}
public function logout(){
$this->session->unset_userdata('admin_name');
$this->session->unset_userdata('admin_id');
$sdata=array();
$sdata['message']='You are successfully logout!';
$this->session->set_userdata($sdata);
redirect('admin_login','refresh');
}
}
?>
And here is my Model code :
<?php
class Super_Admin_Model extends CI_Model{
public function save_category_info($data){
$this->db->insert('tbl_category',$data);
}
}
?>
You forgot to load your model.
public function save_category(){
$this->load->model('super_Admin_Model', 'model'); //May be you forget this.
$data= array(
'category_name' => $this->input->post('category_name',TRUE),
'category_description' => $this->input->post('category_description',TRUE),
'publication_status' => $this->input->post('publication_status',TRUE)
);
$this->model->save_category_info($data);
$sdata=array();
$sdata['message']="Save Category information successfully";
$this->session->set_userdata($sdata);
redirect('super_admin/add_category');
}

Categories