How can I make one layout for all pages? For example I have:
header.blade.php file with my header.
<!doctype html>
<head>
<meta charset="utf-8">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js">
</script>
</head>
<body>
And in login.blade.php:
#extends('layouts.header')
<form method="POST" action="/auth/login">
{!! csrf_field() !!}
<div>
Email
<input type="email" name="email" value="{{ old('email') }}">
</div>
<div>
Password
<input type="password" name="password" id="password">
</div>
<div>
<input type="checkbox" name="remember"> Remember Me
</div>
<div>
<button type="submit">Login</button>
</div>
</form>
</body>
But when I open login page my header prints after login? Why ?
Like this:
Maybe exists easier way to use one header/footer for all pages? For example:
#extends('layouts.header')
~~somethingfile.php~~
#extends('layouts.footer')
Thanks in advance
You would normally create a layout file like this:
<html>
<head>
<title>App</title>
</head>
<body>
#yield('header')
<div class="container">
#yield('content')
</div>
#yield('footer')
</body>
</html>
And every other file extends this file with #extends('layout.layout'), having its own contents in #section.
#section('content')
// content
#endsection
or
#section('header')
// content
#endsection
depending on the purpose, and so on.
Have a look on the documentation
In the end of the header file content insert
#yield('content')
Then when you can write this
#extends('layouts.header')
#section('content')
~somethings~
#stop
#extends('layouts.footer')
I think this may help you.
Related
im trying to create a custom page in WordPress i did some research and what you need to do is to create a .php file in the theme folder that include this code:
<?php /* Template Name: login */ ?>
this one php file that you include this cod in work great but in my case it's a registration form and it does have a link to another .php file which is register.php and when i try to go for that link it will say :"This page doesn't seem to exist" even though both .php files are in the same directory and i even tried to include full path in the link didn't work my full login.php file is like this:
<?php include('server.php') /* Template name: login*/ ?>
<!DOCTYPE html>
<html>
<head>
<title>login</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="header">
<h2>Login</h2>
</div>
<form method="post" action="login.php">
<?php include('errors.php'); ?>
<div class="input-group">
<label>Username</label>
<input type="text" name="username" >
</div>
<div class="input-group">
<label>Password</label>
<input type="password" name="password">
</div>
<div class="input-group">
<button type="submit" class="btn" name="login_user">Login</button>
</div>
<p>
Not yet a member? Sign up<!-- problem is here -->
</p>
</form>
</body>
</html>
when i click on register it take me to :http://localhost/wordpress/login/register.php (login title of the page) and say it doesnt exist
instead of opening the register.php file in the same directory
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Creative - Bootstrap 3 Responsive Admin Template">
<meta name="author" content="GeeksLabs">
<meta name="keyword" content="Creative, Dashboard, Admin, Template, Theme, Bootstrap, Responsive, Retina, Minimal">
<link rel="shortcut icon" href="img/favicon.png">
<title>welcome</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-theme.css" rel="stylesheet">
<link href="css/elegant-icons-style.css" rel="stylesheet" />
<link href="css/font-awesome.css" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet">
<link href="css/style-responsive.css" rel="stylesheet" />
</head>
<body class="login-img3-body">
<div class="container">
<form class="login-form" action="{{ route('login') }}">
{{ csrf_field() }}
<div class="login-wrap">
<p class="login-img"><i class="icon_lock_alt"></i></p>
<div class="input-group">
<span class="input-group-addon"><i class="icon_profile"></i></span>
<input type="text" name="Username" class="form-control" placeholder="Username" autofocus>
</div>
<div class="input-group">
<span class="input-group-addon"><i class="icon_key_alt"></i></span>
<input type="password" name="password" class="form-control" placeholder="Password">
</div>
<label class="checkbox">
<input type="checkbox" value="remember-me"> Remember me
<span class="pull-right"> Forgot Password?</span>
</label>
<button class="btn btn-primary btn-lg btn-block" type="submit">Login</button>
<button class="btn btn-info btn-lg btn-block" type="submit">Signup</button>
</div>
</form>
<div class="text-right">
<div class="credits">
Developer::prakash
</div>
</div>
</div>
</body>
</html>
Its my blade file ,but it cant work properly how can i do it workable ?? i think it problem on action="{{ route('login') }} when i click login bottom it shows
Whoops, looks like something went wrong.
MethodNotAllowedHttpException in RouteCollection.php line 251: How can i solve this??
You are missing method='post', I hope you have declared the route correctly in routes.php
Route::post('/post-form', 'YourController#saveDataFunction'); declare the route properly, if the method is GET write it as Route::GET else this would work fine.
MethodNotAllowedHttpException clearly means the route is not found, means it's missing in the collection OR you declared it differently.
If you don't specify method attribute GET is assumed. This exception means that Laravel couldnot find the specified route.
Which in your case appears to be that you have declared a post route in your routes/web.php file.
Either, edit your web.php file OR specify a method="post" attribute on your form.
I have following view
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
</head>
<body>
<ul class="nav nav-tabs">
<li role="presentation" class="active">Home</li>
<li role="presentation">Profile</li>
<li role="presentation">Messages</li>
</ul>
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</body>
</html>
And used following code to generate pdf file
public function pdf()
{
$view = view()->make('Article::print');
$contents = $view->render();
$pdf = PDF::loadHTML($contents)->setPaper('a4', 'landscape')->setWarnings(false);
return $pdf->download('santosh.pdf');
}
But it does not give correct output rather it return
How can i solve it , please help
You cannot pdf with complex design but you do can create pdf with simple design having simple css.
DomPDF supports limited number CSS items. If you need to complex html into PDF, please use wkhtml2pdf. It gives better output
The current release of Dompdf (0.7.0) has limited support for Bootstrap-based styling (see the relevant issue). With the 0.7.1 Dompdf will come closer to being able to render your document, but I would still not recommend it until the following release (0.7.2?) because it is still missing some necessary capability with regard to the box-sizing CSS property.
I cannot seem to link my login page to my home page, any help would be much appreciated. I know its connecting to the database as i can create users but for some reason its not letting me sign in with a created user.
<?php require ("insert.php"); ?>
<?php
if(isset($_POST[ 'Login' ]))
{
$email= mysqli_real_escape_string($con, $_POST ['email']);
$pswrd= mysqli_real_escape_string($con, $_POST ['pswrd']);
$result = $con->query (" select * from users where email='$email' AND pswrd='$pswrd' ");
$row = $result->fetch_array(MYSQLI_BOTH);
session_start();
$_SESSION["User ID"] = $row['UserID'];
header ('Location: home.php');
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>AMSadler login</title>
<meta charset="utf-8">
<meta name="description" content="description of webpage">
<meta name="keywords" content="keywords go here">
<meta name="author" content="Anthony">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/login.css">
<link rel="index" href="index.php">
<link rel="icon" href="img/favicon.png" sizes="16x16" type="image/png">
</head>
<body>
<div class="header">
<div id="logo">
<img src="img/logo.png" alt="logo" title="AMSadler.com"/>
</div>
<div id="signup">
<button type="button">Sign up</button>
</div>
</div>
<div id="login">
<form>
<input type="text" name="email" placeholder="Email address">
<br>
<input type="password" name="password" placeholder="Password">
<br>
<input id="Login" type="submit" name="Login" value="Login">
</form>
</div>
<footer>
<div id="copyright">
<p>© Copyright 2015</p>
</div>
</footer>
</body>
</html>
You need to change your form tags.
From,
<form>
To,
<form action="yourPageName.php" method="post">
You need to specify your method type so in your PHP code you can get it using that method. If you leave out the method part it by default uses $_GET. Seeing as your code is pointing to $_POST then you set it to method="post".
You also need to set action="" this can be set to # for same page or leave it blank or using a file name. This will redirect the form to that page.
I have got a html like this:
<!doctype html>
<html manifest="">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
</head>
<body>
<div data-role="page" id="Find">
<div data-theme="b" data-role="header" data-position="fixed">
<h3>test</h3>
</div>
<div data-role="content">
<form action="handler.php" id="findForm" >
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<label for="textinputf1"> keyword: </label> <input id="textinputf1" name="keyword" placeholder="" value="" type="text" />
</fieldset>
</div>
<input type= "submit" data-theme="g" value="Find" />
</form>
</div>
</div>
<div data-role="page" id="Results">
<div data-theme="b" data-role="header" data-position="fixed">
<h3>Results</h3>
</div>
<div data-role="content">
<ul data-role="listview" data-filter="true">
<li>HEllo</li>
<li>Bye</li>
</ul>
</div>
</div>
</body>
</html>
a handler.php like this:
<?php
//...
if( let's say false ) {
header("location:.");
}else{
header("location:./#Results");
//header("Refresh:0;url=/application/test/#Results");
}
with header+refresh or with header+location, when I submit the form, I see this in url bar:
.../handler.php?keyword=test
but I'm not redirected, and if I refresh the page (hit enter from the url bar or F5) THEN I get to the #Results, but not automatically
any idea how to fix that?
jquery mobile probably uses ajax to handle your form. You should switch of ajax handling for the form
jQuery Mobile form sample
Also put a space in your location
Location: whereyouwanttogo
Way to see the passed parameters without refresh is by putting data-ajax="false"
If you wish to use ajax, do not call urls directly. Call these with AJAX and based on response redirect to #Results with the help of JavaScript.