Blank Page in Google Chrome - php

Try to load my own created page with using Laravel + Blade, but then the browser only displays the output a sec then disappears. I have no idea what is going wrong, everything in my code doing fine and without errors... Any thoughts???
I'm running this page using php -S 127.0.0.1:8000 -t public
This is web.php:
Route::get('/products/create', 'ProductsController#create');
This is ProductsController.php:
public function create(){
return view('products.create');
}
This is create.blade.php:
#extends('layouts.app')
#section('content')
<div class="container">
<h1>Add new product</h1>
<form action="/products" method="POST">
#csrf
<div class="container">
<div class="form-group row">
<label for="pName" class="col-md-4 col-form-label">Product name</label>
<input id="pName"
name="pName"
type="text"
class="form-control #error('pName') is-invalid #enderror"
value="{{ old('pName') }}"
autocomplete="pName"
autofocus>
</div>
<div class="form-group row">
<label for="pCat" class="col-md-4 col-form-label">Category</label>
<input id="pCat"
name="pCat"
type="text"
class="form-control #error('pCat') is-invalid #enderror"
value="{{ old('pCat') }}"
autocomplete="pCat"
autofocus>
</div>
</div>
<button class="btn btn-primary" type="submit">Submit</button>
</form>
</div>
#endsection
Here's the webpack.mix.js:
const mix = require('laravel-mix');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')
.mixbrowserSync('localhost:8000');
It seems like the #extends('layouts.app') is not working, because when I removed it, the page could run tho. Any solution to solve it or did missing some dependencies to install??

Look in your Laravel log file normally located at /storage/logs/laravel.log
And you may want to serve it with artisan instead:
php artisan serve
Local Development Server If you have PHP installed locally and you
would like to use PHP's built-in development server to serve your
application, you may use the serve Artisan command. This command will
start a development server at http://localhost:8000:
https://laravel.com/docs/master/logging
https://laravel.com/docs/master/installation

Related

Route [customer.password.request] not defined

I am trying to get my development box to work so I can work on a development at home as not to alter and mess up the main site.
I get an error on the development box but not on the main site.
I have set everything up then copied the site via another tutorial. I was able to get all the requirements working and the site works except when I attempt to go to the log in page. I have searched the web for the method used for the route and I cannot find a good explanation of how it works so I can troubleshoot the problem.
div class="col-lg-6 col-md-8 col-sm-8 col-lg-offset-3 col-md-offset-1 col-sm-offset-2">
#if(Session::has('errors'))
<div class="alert alert-danger text-center">
#php ($errors = Session::get('errors'))
#php ($err = $errors->toArray())
{{$err['email'][0]}}
</div>
#endif
<form role="form" id="cust-login-frm" method="POST" action="{{ route('xxx') }}" >
{{csrf_field()}}
<input name="user_type" type="hidden" value="{{ Crypt::encrypt('XX') }}">
<div class="form-group">
<label>Email</label>
<input type="email" id="email" name="email" class="form-control" placeholder="Email" value="{{(Session::has('failed')) ? Session::get('failed') : ''}}">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" id="password" name="password" class="form-control" placeholder="Password">
</div>
<div class="clearfix"></div>
</form>
<div class="form-group col-lg-12 submitbtn">
<!-- <input type="hidden" name="save" value="contact"> -->
<button id="cust-login-btn" class="btn btn-primary" type="button">Sign In</button>
</div>
<center><div> Not Registrated? Register | Forgot Password? </div></center>
The issue I am having is the hyperlink towards the bottom "{{route('customer.password.request') }}" The route before it I can find and follow but this one with the dot notation I cannot. I cannot provide too many details as this is a live site. I suspect this broke due to my command composer update. The main site was not coded by me and has tons of issues. But it will work and its the same. This one is difficult as the main laravel.org does not have much on the subject. If a guru here can point me to a tutorial or page that will help me understand why I am getting the error "Route [customer.password.request] not defined. (View: /var/www/html/resources/views/customer/auth/xxx.blade.php)". Thanks community. :)
NOTE: I have removed some parts to hide real filenames with xxx.
Define the route name in web.php
Route::any('urlname','controllername#functionname')->name('customer.password.request');
Ok the answer to my question here is this.
I found out that the routes were placed in the wrong location.
The morons who did this put the routes in the vender folder file. This was changed when I did an update. So I decided to move them to the web.php and it worked.
So this issue can be closed.
Thanks.

#csrf is not working in Laravel 5.4

I am following this tutorial on Laravel and I've noticed that I cannot use the #csrf command, but others can use it effectively. But, I can use the {{ csrf_field() }} for the csrf token. I would like to know the reason why. Thanks.
Here's my screenshot on using the #csrf command: Image here
Here's my index.blade.php
<form action="{{ route('contact.store') }}" method="post">
#csrf
<div class="col-md-6 mb-3">
<label for="username">Username:</label>
<input class="form-control" type="text" name="name" id="username" placeholder="Username | Email | Phone Number" required>
<div class="invalid-feedback">
Please provide a username
</div>
</div>
<div class="col-md-6 mb-3">
<label for="password">Password:</label>
<input class="form-control" type="password" name="name" id="password" placeholder="" required>
<div class="invalid-feedback">
Please provide a password
</div>
</div>
<div class="col-md-6 mb-3">
<input type="submit">
</div>
</form>
As far as I know, there is no #csrf in 5.4, you must use
{{ csrf_field() }}
Instead, #csrf is available in laravel 5.6
#csrf argument came to blade with 5.6
you need to use csrf_field() method instead #csrf
for more information check out the docs
Laravel 5.4 only available
refer to this link
https://laravel.com/docs/5.4/csrf
{{ csrf_field() }}
And Laravel 5.6 available
refer to this link
https://laravel.com/docs/5.6/csrf
#csrf
if you used to laravel framework version 5.6, 5.5 or less than version 5.5
you should write {{ csrf_field() }}, but if you used to laravel framework version 5.7, 5.8 or bigger than version 5.7 you should write #csrf
Laravel 5.5, 5.6 => write {{ csrf_field() }}
Laravel 5.7, or bigger than 5.7 => write #csrf

Laravel routes are not found in 000webhost

I'm building a simple blog for my personal projects with Laravel 5.4.36. I have uploaded it to 000webhost. The problem is everytime I`m trying to sign up or sign in, it is saying,
The requested URL was not found on this server
Here is the URL that is shown during this error,
https://myprojectblog.000webhostapp.com/signUp
Here 'signUp' or 'signIn' are provided in the routes file which are given below,
Route::post('/signUp', [
'uses'=>'UserController#postSignUp',
'as'=>'signUp'
]);
Route::post('/signIn', [
'uses'=>'UserController#postSignIn',
'as'=>'signIn'
]);
The sign up form is given below,
<div class="signUp">
<label>Sign Up</label></br>
<form action="{{ route('signUp') }}" method="POST" name="signUp" id="signUp">
<label id="usernameLabelSignUp">Username</label></br>
<input type="text" id="usernameSignUp" name="username" value="{{ Request::old('username')}}"></br>
<label id="emailLabelSignUp">Email</label></br>
<input type="text" id="emailSignUp" name="email" value="{{ Request::old('email')}}"></br>
<label id="passwordLabelSignUp">Password</label></br>
<input type="password" id="passwordSignUp" name="password"></br>
<input type="hidden" name="_token" value="{{ Session::token() }}">
<input type="submit" id="signUpSubmit" value="signUp">
</form></br>
</div>
In the cpanel of 000webhost my file structure is,
/
-Blog
-All the Laravel project directories and files except public
-public_html
-public
-css
-js
-.htacess
-index.php
-favicon.ico
-robots.txt
-web.config
My index.php in /public_html/public got included these lines,
require __DIR__.'/../Blog/bootstrap/autoload.php';
$app = require_once __DIR__.'/../Blog/bootstrap/app.php';
The index page loads without any trouble, but while trying to sign in or up the error occurs.
Most importantly everything runs absolutely fine in my local machine, no trouble at all.
Some clue would mean great help. Thank you.

Unable to load the "Symfony\Bridge\Twig\Form\TwigRenderer" runtime

I've been working through various hurtles toward migrating an existing Symfony3 web app from a local LAMP host up to Goggle's App Engine Standard PHP Environment. I've taken hints from the appengine-symfony-starter-project to use Memcache for sessions, pre-cache the application code, and connect to a Cloud SQL MySQL database. In have the core pieces working fine.
I added a login form at /login using a TWIG template with a form in it that goes like so:
<form class="form" action="{{ path('security_login') }}" method="post">
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" />
<div class="form-group">
<input class="form-control" id="email" type="text" name="_email" placeholder="Email" value="{{ last_username }}"/>
</div>
<div class="form-group">
<input class="form-control" id="password" type="password" name="_password" placeholder="Password"/>
</div>
<div class="form-group">
<input type="checkbox" id="remember_me" name="_remember_me" checked>
<label for "remember_me">Remember Me</label>
</div>
<div class="form-group">
<button class="btn btn-round btn-b">Login</button>
</div>
<div class="form-group">Forgot Password?</div>
</form>
This works fine in the local DEV and TEST environments but when I push this up to GAE, I'm getting the error below:
Unable to load the "Symfony\Bridge\Twig\Form\TwigRenderer" runtime.
I've been digging for a couple hours now and haven't found a hit as to what's wrong here. Anyone have any ideas where to look?
Thanks in advance,
In my case "twig.strict_variables: true" to "twig.strict_variables: false" fixed an issue.
We encountered the same error this morning at work, in a Silex app.
This helped us: https://github.com/silexphp/Silex/pull/1571
It worked for us to change in our composer.json the version of symfony/form from ~2.8|^3.0 to ~2.8|3.3 as it appears TwigRenderer is deprecated in 3.4.
Hope this helps.

I can't run PHP code with HTML [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm working on my website and it includes php / html / css . i want to save user information and here my html codes ;
<div class="container-fluid">
<form class="form-signin" action="" method="post" style="max-width:500px; margin-left:auto; margin-right:auto;">
<h2 class="form-heading">Yeni Musteri Kayit</h2>
<div class="panel panel-success">
<div class="panel-body">
<div class="form-group">
<label for="adsyd">Ad Soyad</label>
<input type="text" id="adsyd" name="adsoyad" class="form-control" placeholder="Ad Soyad" required autofocus>
</div>
<div class="form-group">
<label for="name">Telefon Numarasi</label>
<input type="text" id="tel" name="tel" class="form-control" placeholder="Telefon Numarası" required autofocus>
</div>
<div class="form-group">
<label for="surname">Adres</label>
<input type="text" id="adres" name="adres" class="form-control" placeholder="Adres" required autofocus>
</div>
<div class="form-group">
<label for="surname">Kayit Tarihi</label>
<input type="text" id="kyt" name="kyt" class="form-control" placeholder="Kayıt Tarihi" required autofocus>
</div>
</div>
</div>
<button class="btn btn-success btn-block" type="submit">Kaydet</button>
</form>
</div>
<?php
if(isset($_POST['adsoyad'])) {
$db = new mysqli('localhost', 'root', '1234', 'esranur');
if($db->connect_errno) die ('Bağlantı hatası:' . $db->connect_errno);
$stmt=$db->prepare("insert into musteri values (NULL,?,?,?,?)");
if($stmt === FALSE) die("Sorgu hatası". $db ->error);
$stmt->bind_param("sss", $_POST['adsoyad'],$_POST['telefon'],$_POST['adres']);
$stmt->execute();
?>
I dont have problem with html and css codes but when i try to add php code after last div it doesn't recognize the code, it recognize like text and doesn't run code, just print like text. Am I doing it with wrong place? I working with netbeans. Thank you
create a folder test in C:/xampp/htdocs/, result : C:/xampp/htdocs/test
copy all project to test folder.
open a browser and go to this address: http://localhost/test
You must have an active apache service on your machine(Ex. Windows).
apache must be in run mode without error!
all .html files that have php code in it, muse change to .php
If http://localhost/test not work, write your file name end of address(Ex. http://localhost/test/my_file.php);
i still have same problem. i moved my project file into xampp/htcdocs. here my path ; file:///C:/xampp/htdocs/mine/new.php and here my php code;
You are not running your file on localhost and rather file:///
Change your url from this:
file:///C:/xampp/htdocs/mine/new.php
to this:
http://localhost/mine/new.php
Install a apache webserver server for example wamp:
http://www.wampserver.com/en/
Watch some tutorials about it.
Put a info.php file on your server having code
<?php phpinfo(); ?>
if this code execute and show you server information then your server configuration is ok and your file name is added with some other extention, if not then you need to first setup it.

Categories