I am very new to Laravel and I have been given a very old project and asked to use vagrant/homestead. The project uses php7.2 and doesn't have php artisan. It also doesn't have public folder. The problem is that the I am getting a blank view with status code 200. My homestead.yaml is:
folders:
- map: C:\Users\Desktop\school_erp_lms
to: /home/vagrant/school_lms
sites:
- map: school-lms.test
to: /home/vagrant/school_lms
php: "7.2"
databases:
- u789138695_schoolerp
route.php is:
Route::get('/login','LoginController#index');
LoginController is:
<?php
namespace App\Http\Controllers;
use View;
class LoginController extends Controller
{
public $data = array();
public function __construct()
{
$this->panelInit = new \DashboardInit();
$this->data['panelInit'] = $this->panelInit;
}
public function index()
{
return View::make('login', $this->data);
}
}
.env is:
DB_NAME=u789138695
DB_USERNAME=user
DB_PASSWORD=""
DEBUG=true
login.blade.php is:
<!DOCTYPE html>
<html lang="en" <?php if($panelInit->isRTL == 1){ ?>dir="rtl"<?php } ?> style="background:none;">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<!-- Favicon icon -->
<?php if($panelInit->settingsArray['favicon'] == "e"){ ?>
<link rel="icon" type="image/png" sizes="16x16" href="{{URL::asset('assets/images/favicon.png')}}">
<?php } ?>
<title><?php echo $panelInit->settingsArray['siteTitle'] . " | " . $panelInit->language['signIn']; ?></title>
<!-- Bootstrap Core CSS -->
<link href="{{URL::asset('assets/plugins/bootstrap/css/bootstrap.min.css')}}" rel="stylesheet">
<!-- Custom CSS -->
<?php if($panelInit->isRTL == 1){ ?>
<link href="{{URL::asset('assets/css/style-rtl.css')}}" rel="stylesheet">
<link href="{{URL::asset('assets/plugins/bootstrap-rtl-master/dist/css/custom-bootstrap-rtl.css')}}" rel="stylesheet" type="text/css" />
<?php }else{ ?>
<link href="{{URL::asset('assets/css/style.css')}}" rel="stylesheet">
<?php } ?>
<link href="{{URL::asset('assets/css/custom.css')}}" id="theme" rel="stylesheet">
<!-- 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>
<?php
$bgStyling = "";
if($panelInit->settingsArray['authPageImage'] == "1"){
$bgStyling .= "background-image:url('".URL::asset('assets/images/login-register.jpg')."'); ";
}
if($panelInit->settingsArray['authPageColor'] != ""){
$bgStyling .= "background-color:".$panelInit->settingsArray['authPageColor'].";";
}
?>
<body class="loginMark" style="<?php echo $bgStyling; ?>;background-attachment:fixed; background-repeat: repeat-y;background-size: cover;" >
<!-- ============================================================== -->
<!-- Preloader - style you can find in spinners.css -->
<!-- ============================================================== -->
<div class="preloader">
<svg class="circular" viewBox="25 25 50 50">
<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" /> </svg>
</div>
<!-- ============================================================== -->
<!-- Main wrapper - style you can find in pages.scss -->
<!-- ============================================================== -->
<section id="wrapper" <?php if($panelInit->settingsArray['loginPageStyle'] == "r"){ echo 'class="login-register login-sidebar" style="'.$bgStyling.'"'; } ?>>
<div <?php if($panelInit->settingsArray['loginPageStyle'] == "r"){ echo 'class="login-box card"'; }else{ echo 'class="login-register" '; } ?> >
<?php if($panelInit->settingsArray['loginPageStyle'] == "c"){ ?><div class="login-box card"><?php } ?>
<div class="card-block">
<form class="form-horizontal form-material" id="loginform" action="{{URL::to('/login')}}" method="post">
<a href="javascript:void(0)" class="text-center db logo-text-login">
<?php
if($panelInit->settingsArray['siteLogo'] == "siteName"){
echo $panelInit->settingsArray['siteTitle'];
}elseif($panelInit->settingsArray['siteLogo'] == "text"){
echo $panelInit->settingsArray['siteLogoAdditional'];
}elseif($panelInit->settingsArray['siteLogo'] == "image"){
?><img src="<?php echo URL::asset('assets/images/logo-light.png'); ?>" /><?php
}
?>
</a>
<h3 class="box-title m-b-20"><?php echo $panelInit->language['signIn']; ?></h3>
#if($errors->any())
<span style='color:red;'>{{$errors->first()}}</span><br/><br/>
#endif
<div class="form-group ">
<div class="col-xs-12">
<input class="form-control" type="text" name="email" required="" placeholder="<?php echo $panelInit->language['userNameOrEmail']; ?>">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<input class="form-control" type="password" name="password" required="" placeholder="<?php echo $panelInit->language['password']; ?>">
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<div class="checkbox checkbox-primary pull-left p-t-0">
<input id="checkbox-signup" name="remember_me" type="checkbox">
<label for="checkbox-signup"> <?php echo $panelInit->language['rememberMe']; ?> </label>
</div> <i class="fa fa-lock m-r-5"></i> <?php echo $panelInit->language['restorePwd']; ?> </div>
</div>
<div class="form-group text-center m-t-20">
<div class="col-xs-12">
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
<button class="btn btn-info btn-lg btn-block text-uppercase waves-effect waves-light" type="submit"><?php echo $panelInit->language['signIn']; ?></button>
</div>
</div>
<?php if(isset($panelInit->settingsArray['allowPublicReg']) AND $panelInit->settingsArray['allowPublicReg'] == "1"){ ?>
<div class="form-group m-b-0">
<div class="col-sm-12 text-center">
<p><b><?php echo $panelInit->language['registerNewAccount']; ?></b></p>
</div>
</div>
<?php } ?>
<div class="form-group m-b-0">
<div class="col-sm-12 text-center">
<p><b><?php echo $panelInit->language['schoolTerms']; ?></b></p>
</div>
</div>
</form>
</div>
<?php if($panelInit->settingsArray['loginPageStyle'] == "c"){ ?></div><?php }?>
</div>
</section>
<script src="{{URL::asset('assets/plugins/jquery/jQuery-2.1.4.min.js')}}"></script>
<!-- Bootstrap tether Core JavaScript -->
<script src="{{URL::asset('assets/plugins/bootstrap/js/tether.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/bootstrap/js/bootstrap.min.js')}}"></script>
<!-- slimscrollbar scrollbar JavaScript -->
<script src="{{URL::asset('assets/js/jquery.slimscroll.js')}}"></script>
<!--Wave Effects -->
<script src="{{URL::asset('assets/js/waves.js')}}"></script>
<!--stickey kit -->
<script src="{{URL::asset('assets/plugins/sticky-kit-master/dist/sticky-kit.min.js')}}"></script>
<!--Custom JavaScript -->
<script src="{{URL::asset('assets/js/custom.min.js')}}"></script>
<?php if( isset($panelInit->settingsArray['gTrackId']) AND $panelInit->settingsArray['gTrackId'] != "" ): ?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '<?php echo $panelInit->settingsArray['gTrackId']; ?>', 'auto');
ga('send', 'pageview');
</script>
<?php endif; ?>
</body>
</html>
The "login.blade.php" file exists under resources/views. The response I am getting is a blank screen with status code 200. I have tried other blades also inplace of login and still got the same response. But when I provided an invalid blade name, I got an error saying blade doesn't exist. Any help is appreciated.
What the problem is
Hmmm... To be honest - I'm not sure. I can't really find any bad part of what you're posted.
Maybe it's a caching error.
Solution suggestions
You say that you don't have php artisan working. Hmm... How do you clear the cache then? The command: php artisan cache:clear
None the less... The first command that comes to mind is to try and clear the cache and generates composer-files, with this command:
php artisan cache:clear && composer dump-autoload
But if you can't do php artisan, then maybe just do: composer dump-autoload
Further debugging
If it was me, then I would start at the routes, changing this:
Route::get('/login','LoginController#index');
to this:
dd('hey');
Route::get('/login','LoginController#index');
And then reloading the page. You should then see it say 'Hey' on the screen.
... If that works, then change it to this:
Route::get('/login','LoginController#index');
dd('hey');
Then it _SHOULDN'T say 'Hey' on the screen.
... Then I would work my way through the controller as well.
And afterwards through the view.
To find the place where it deviates what you expect should happen and what really happens.
Fun fact:
I have tried once, where I did this - and moved the dd-statement aaaaaall the way through my code. And in the end, when I simply removed the dd-statement then the unexpected behaviour was gone. It must have been some caching or something.
Related
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 -->
So i have this page setup for my private game server. I host the game server and web on the same dedicated server running windows server 2016. I use IIS to host the website. Right now am facing a problem, page only loads after reloading for 2-3 times. Till then it returns HTTP error 500. Once the page is loaded, i have to refresh multiple times to load each content. What is going on ?
Page -> www.ram-sro.com
Index.php
<?php
include("_incl/config.inc.php");
$sec = new Security();
$conf = new Config();
$mssql = new mssql();
$mssql->dbOpen($conf->accountDbName);
$modDir = "mod/";
$modExt = ".php";
session_start();
?>
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title><?php echo "$conf->siteName" ?></title>
<link type="text/css" rel="stylesheet" media="all" href="css/style.css" />
<link rel="shortcut icon" href="img/favicon.png" type="image/x-icon" />
<meta name="description" content="<?php echo $conf->description; ?>" />
<meta name="keywords" content="<?php echo $conf->keywords; ?>" />
<script type="text/javascript">
<!--
function clearText(formfield){
if (formfield.defaultValue==formfield.value) {
formfield.value = ""
}
}
-->
</script>
</head>
<body>
<center>
<div id="page-body">
<div class="page-body topbox">
<div class="page-body blackspace"></div>
<div class="page-body topbox-content">
<div class="topbox-webtitle">
</div>
<div class="topbox-user">
<div class="social-networks">
<img src="img/fb-icon.png" width="40px" height="40px;" alt="Visit us at facebook!" />
<img src="img/tw-icon.png" width="40px" height="40px;" alt="Visit us at twitter!" />
</div>
<div class="form">
<?php include($modDir."user".$modExt);?>
</div>
</div>
</div>
</div>
<div class="page-body spacer"></div>
<div class="page-body menubox">
<div class="menubox-content">
<div id="menubar">
<ul>
<?php
include($modDir."menu".$modExt);
?>
</ul>
</div>
</div>
</div>
<div class="page-body spacer"></div>
<div class="page-body content">
<div class="page-body leftblock">
<?php
include($modDir."page".$modExt);
?>
</div>
<div class="page-body rightblock">
<?php
include($modDir."social".$modExt);
?>
<div class="page-body spacer"></div>
<div class="page-body info">
<?php
include($modDir."info".$modExt);
?>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</center>
</body>
</html>
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.
I'm creating a regitration page which includes php,html and css in bootstrap.Here is my php file.
<?php include "header.php"; ?>
<html>
<head></head>
<body>
<!--content-->
<div class=" container">
<div class=" register">
<h1>Register</h1>
<?php if(isset($_GET[ 'error'])) { echo '<font color="red">'.$_GET[ 'error']. '</font>'; echo '<br><br>'; } if(isset($_GET[ 'ok'])) { echo '<font color="blue">You are successfully Registered..</font>'; echo '<br><br>'; } ?>
<form action="process_register1.php" method="POST">
</div>
<div class="col-md-6 register-bottom-grid">
<h3>Personal infomation</h3>
<div>
<span>Full Name</span>
<input type="text" size="30" maxlength="30" name='fnm'>
</div>
<div>
<span>Username</span>
<input type="text" size="30" maxlength="30" name='unm'>
</div>
<div>
<span>Password</span>
<input type='password' name='pwd' size="30">
</div>
<div>
<span> Confirm password</span>
<input type='password' name='cpwd' size="30">
</div>
<div>
<span> Gender</span>
<input type="radio" value="Female" name="gender" id='f'>Female
<input type="radio" value="Male" name="gender" id='m'>Male
</div>
<div>
<span>E-mail address</span>
<input type='mail' name='mail' size="30">
</div>
<div>
<span> No contact</span>
<input type="text" name='contact' size="30">
</div>
<div>
<span> City</span>
<select style="width: 195px;" name="city">
<option>Tirana</option>
<option>Korca</option>
<option>Vlora</option>
<option>Kavaja</option>
</select>
</div>
<input type="submit" value="submit">
</div>
<div class="clearfix"></div>
</form>
</div>
</div>
</body>
</html>
Here is my header.php file:
<?php session_start(); require( 'config.php'); ?>
<!DOCTYPE html>
<html>
<head>
<title>Online Shopping</title>
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery.min.js"></script>
<!-- Custom Theme files -->
<!--theme-style-->
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<!--//theme-style-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="New Store Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template,
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
<script type="application/x-javascript">
addEventListener("load", function() {
setTimeout(hideURLbar, 0);
}, false);
function hideURLbar() {
window.scrollTo(0, 1);
}
</script>
<!--fonts-->
<link href='http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900' rel='stylesheet' type='text/css'>
<!--//fonts-->
<!-- start menu -->
<link href="css/memenu.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="js/memenu.js"></script>
<script>
$(document).ready(function() {
$(".memenu").memenu();
});
</script>
<script src="js/simpleCart.min.js">
</script>
</head>
<body>
<!--header-->
<div class="header">
<div class="header-top">
<div class="container">
<div class="search">
<form>
<input type="text" value="Search " onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Search';}">
<input type="submit" value="Go">
</form>
</div>
<div class="header-left">
<?php if(isset($_SESSION[ 'status'])) { echo '<ul><li>Logout</li></ul>'; } else { echo '<ul>
<li ><a href="login1.php" >Login</a></li>
<li><a href="register.php" >Register</a></li>
</ul>'; } ?>
<div class="cart box_1">
<a href="checkout.html">
<h3> <div class="total">
<span class="simpleCart_total"></span> (<span id="simpleCart_quantity" class="simpleCart_quantity"></span> items)</div>
<img src="images/cart.png" alt=""/></h3>
</a>
<p>Empty Cart
</p>
</div>
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
</div>
</div>
<div class="container">
<div class="head-top">
<div class="logo">
<a href="index.html">
<img src="images/logo.png" alt="">
</a>
</div>
<div>
<h1 class="title">Welcome
<?php
if(isset($_SESSION['status']))
{
echo $_SESSION['unm'];
}
else
{
echo 'Book Store';
}
?>
</div>
<div class=" h_menu4">
<ul class="memenu skyblue">
<li class="active grid"><a class="color8" href="index1.php">Home</a></li>
<li><a class="color1" href="#">Categories</a>
<div class="mepanel">
<div class="row">
<?php
$query="select * from category ";
$res=mysqli_query($conn,$query);
while($row=mysqli_fetch_assoc($res))
{
echo' <div class="col1">
<div class="h_nav">
<ul>';
echo '<li>
<a href="subcat.php?cat='.$row['cat_id'].'&catnm='.$row["cat_nm"].'">'.$row["cat_nm"].'
</a>
</li>';
}
echo' </ul>
</div>
</div>';
mysqli_close($conn);
?>
<li><a class="color6" href="contact.html">Contact Us</a></li>
</ul>
</div>
<div class="clearfix"> </div>
</div>
</div>
</div>
The problem is when I try to open the files from localhost only the header of the page appears so this is the result:
How is it possible that the form doesnt appear?
I assume, that your header.php begins a proper html page with doctype, <html> etc... but after
<?php include "header.php"; ?>
you start your html file again:
<html>
<head></head>
<body>
Make sure your markup is valid!
So it looks like your header file isn't a header, it's a complete HTML document. It opens the document (<html>) and then closes it (</html>). So it makes sense that any HTML you put after including the header won't get rendered - the browser will render the header and assume the document is complete.
Instead you header file should end where the markup for the header ends. Usually this is the opening tag for the container of your content.
Then when you include the header file, it will contain all the markup up to where your content begins, and in your form's file you can put the code for the form and it'll get rendered next.
In your case, try removing the </body> and </html> tags from the header file. That will likely work, though your markup will likely need to be updated to make the design coherent. Also, since those are being created by your header, remove the <html>, <head></head>, and <body> tags from your form's file.
You can also create a footer file that you can include after your form content, and it will close the container and the body and html tags.
Edit
May have scrolled to the end of the first code block when I saw the </body></html>, so you can probably disregard the advice to remove them from the header file - they appear to be there only in my imagination. Removing the opening <html>, <body>, and <head> tags from the from file should do the trick however.
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');
}