<!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.
Related
I am trying to use select2 for my laravel Create function. but it does nothing, and i followed multiple tutorials with the same results.
index.blade(my scripts are in the header)
<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">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
<title>Subfolders</title>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" integrity="sha512-nMNlpuaDPrqlEls3IX/Q56H36qvBASwb3ipuo3MxeWbsQB1881ox0cRv7UPTgBlriqoynt35KjEwgGUeUXIPnw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js" integrity="sha512-2ImtlRlf2VVmiGZsjm9bEyhjGW4dU7B6TNwh/hx/iSByxNENtj3WVE6o/9Lj4TJeVXPi4bnOIMXFIJJAeufa0A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
#stack('page_scripts')
</head>
#include('admin.file.create')
here i include the 'create.blade' file
create.blade:
<div class="row">
<div class="col-sm-8 offset-sm-2">
<h1 class="display-3">Add File</h1>
<div>
#if ($errors->any())
<div class="alert alert-danger">
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div><br />
#endif
<form method="post" action="{{ route('admin.file.store') }}" enctype="multipart/form-data">
#csrf
<div class="form-group">
<label for="title">{{('title')}}*</label>
<input type="text" class="form-control" name="title" />
</div>
<div class="form-group">
<label for="value">{{('Short description')}}</label>
<input type="text" class="form-control" name="description_short" />
</div>
<div class="form-group">
<label for="name">{{('Tags')}}*</label>
<select id="tag_ids" name="tag_id[]" class="form-control" multiple>
<option value="">{{('Select Tags')}}</option>
#foreach($tags as $tag)
<option value=" {{$tag->id}}">{{$tag->name}}</option>
#endforeach
</select>
</div>
<p>* required</p>
<button type="submit" class="btn btn-primary">Add File</button>
</form>
</div>
</div>
</div>
#push('page_scripts')
<script>
$(document).ready(function() {
$('#tag_ids').select2();
});
</script>
#endpush
image of the select:
if i need to upload any more information i will gladly do so!
You need to add jQuery CDN and call the select2 function. I have attached a sample code below.
<!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.0">
<title>Select2</title>
<!-- CSS -->
<link href="https://cdn.jsdelivr.net/npm/select2#4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
</head>
<body>
<select class="js-example-basic-single" name="state">
<option value="AL">Alabama</option>
<option value="WY">Wyoming</option>
</select>
<!-- JS -->
<script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2#4.1.0-rc.0/dist/js/select2.min.js"></script>
<script>
$(document).ready(function () {
$('.js-example-basic-single').select2();
});
</script>
</body>
</html>
I have been writing one HTML page i will let below this, and a PHP script i will post too. But when i use the HTML page to write information and submit it, i get the "The requested URL was not found on this server." message, i have all files into one folder on htdocs named "html", the html page is named "index" and the script is named "test", thank you so much for your time.
[HTML code]
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="/docs/4.0/assets/img/favicons/favicon.ico">
<title>Signin Template for Bootstrap</title>
<link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/sign-in/">
<!-- Bootstrap core CSS -->
<link href="../../dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="signin.css" rel="stylesheet">
</head>
<body class="text-center">
<form method="post" action="next.php">
<img class="mb-4" src="https://getbootstrap.com/docs/4.0/assets/brand/bootstrap-solid.svg" alt="" width="72" height="72">
<h1 class="h3 mb-3" font-weight="normal"> Please sign in </h1>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
<p class="mt-5 mb-3 text-muted">© 2017-2018</p>
</form>
</body>
</html>
PHP script
<?php
$handle = fopen("pruebapracticaHE.txt", "a");
foreach($_POST as $variable => $value) {
fwrite($handle, $variable);
fwrite($handle, "=");
fwrite($handle, $value);
fwrite($handle, "\r\n");
}
fwrite($handle, "\r\n");
fclose($handle);
exit
?>
You said that script name is test.php
but what i can see in your HTML code that you set action="next.php" in the form instead of action="test.php" the right code is :
<form method="post" action="test.php">
AT login.blade.php
<!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" method="post" action="{{ url('/dashboard') }}"> //{{ route('login') }}
<input type="hidden" name="_token" value="{{ 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::xxx
</div>
</div>
</div>
</body>
</html>
And web.php
Route::get('/' , ['as' => '/' , 'uses'=> 'loginController#getlogin']);
Route::post('/login', ['as' => 'login', 'uses'=> 'loginController#postlogin']);
Route::group(['middleware' =>['authen']], function ()
{
Route::get('/dashboard',['as'=>'dashboard', 'uses'=> 'dashboardController#dashboard']);
Route::get('/logout' ,['as'=>'logout', 'uses'=> 'loginController#getLogout']);
});
i am newer on laravel . i have this error happen . how to solve and
method="post" action="{{ url('/dashboard') }}"> //{{ route('login') }}
"{{ csrf_field() }} .In here on action field which url should pass .. i mean destination or same path .. i want to redirect to dashboard .. thank you :)
Try to change route
First you need to set login route url in form (action="{{ url('/login') }}") and after submit form in postlogin function use auth and check email password is correct or not.if correct than redirect url is dashboard.
check what ur route is expecting by using
php artisan route:list command in terminal
next change your form method to that
if you want user to redirect to dashboard u need to do it in ur controller`
`class ProfileController extends Controller
{
//your code here
public dashbord(){
// your code
return view("your dashboard view path");
}
I have the below php page, which is a holding page with a contact form:
<!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.0">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="">
<!--<link rel="icon" href="../../favicon.ico">-->
<title>Coming Soon</title>
<!-- Bootstrap -->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<link href="assets/css/bootstrap-theme.css" rel="stylesheet">
<link href="assets/css/font-awesome.css" rel="stylesheet">
<!-- siimple style -->
<link href="assets/css/style.css" rel="stylesheet">
</head>
<body>
<div id="wrapper">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>TEST</h1>
<h2 class="subtitle">We're working hard to improve our website and we'll be ready to launch soon
<h2 class="subtitle">Feel free to contact us below with any enquiries</h2>
<p>
<?php
$name = $_POST["contactname"];
?>
<form class="Contact" method="post" action="">
<label class="alignleft">Name</label>
<input type="text" name="contactname" id="contactname" placeholder="Enter Name">
<label class="alignleft">Email</label>
<input name="Email" placeholder="Email Address">
<label class="alignleft">Enquiry</label>
<textarea name="Enquiry" placeholder="Your enquiry"></textarea><br>
<input id="submit" name="submit" type="submit" value="Submit!" class="btn btn-theme">
</form>
<div class="social">
<i class="fa fa-facebook" aria-hidden="true"></i>
<i class="fa fa-twitter" aria-hidden="true"></i>
<!--<i class="fa fa-google-plus" aria-hidden="true"></i>
<i class="fa fa-linkedin" aria-hidden="true"></i>-->
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
</body>
</html>
Within the php section I am trying to read the values of the input boxes, however even with only
$_POST["contactname"];
the website returns a 500 Internal Server Error. If i remove that line and replace with a simple:
echo "Test";
Then the site works and displays "Test"
If there something I am missing with the assigning of the variable from the input box?
You should make sure the key of the POST array is set and then validate your values first before you show them, and be sure to handle errors and invalid values!
if(isset($_POST["contactname"])){
// Do validation, like making sure its not a empty string
if (!empty($_POST["contactname"])) {
echo $_POST["contactname"];
} else {
echo "A validation error";
}
}
Also enable PHP error output which will greatly help you debug issues like this:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
And display_errors = on in your php.ini to make PHP show parse errors.
I would recommend using a second file to process the form instead of having it all on one page. Not only does it make your code look cleaner but I find it can also help with debugging. So it will look something like this:
index.php:
<!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.0">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="">
<!--<link rel="icon" href="../../favicon.ico">-->
<title>Coming Soon</title>
<!-- Bootstrap -->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<link href="assets/css/bootstrap-theme.css" rel="stylesheet">
<link href="assets/css/font-awesome.css" rel="stylesheet">
<!-- siimple style -->
<link href="assets/css/style.css" rel="stylesheet">
</head>
<body>
<div id="wrapper">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>TEST</h1>
<h2 class="subtitle">We're working hard to improve our website and we'll be ready to launch soon
<h2 class="subtitle">Feel free to contact us below with any enquiries</h2>
<form class="Contact" method="post" action="form_process.php">
<label class="alignleft">Name</label>
<input type="text" name="contactname" id="contactname" placeholder="Enter Name">
<label class="alignleft">Email</label>
<input name="Email" placeholder="Email Address">
<label class="alignleft">Enquiry</label>
<textarea name="Enquiry" placeholder="Your enquiry"></textarea><br>
<input id="submit" name="submit" type="submit" value="Submit!" class="btn btn-theme">
</form>
<div class="social">
<i class="fa fa-facebook" aria-hidden="true"></i>
<i class="fa fa-twitter" aria-hidden="true"></i>
<!--<i class="fa fa-google-plus" aria-hidden="true"></i>
<i class="fa fa-linkedin" aria-hidden="true"></i>-->
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
</body>
</html>
form_process.php:
<?php
if(isset($_POST['contactname'])
{
$name = $_POST['contactname'];
if(empty($name))
{
die("contact name is empty")
}
else
{
echo $name;
}
}
// Continue processing form data
?>
I would also follow the recommendations from other users about displaying PHP errors.
You should validate it first
if(isset($_POST['contactname'])){
// Do your post handling
}
Firstable , you need to check if $_POST is defined , and not empty :
if(isset($_POST["contactname"]) && !empty($_POST["contactname"])){
echo $_POST["contactname"];
}
Second , i think you need to configure you'r server to show errors and not to redirect you to 500 error:
Just modify your php.ini with this line:
display_errors = on
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.