Can i be hacked if i public a file php in public folder in laravel 5 -
i have example.php , move public folder in laravel
example.php:
<html> <body> <form action="welcome.php" method="post"> name: <input type="text" name="name"><br> e-mail: <input type="text" name="email"><br> <input type="submit"> </form> </body> </html> and welcome.php:
<?php $name = $_post['name']; $email = $_post['email']; echo "your name: ".$name; echo "your email: ".$email; ?> and result:
your name: john email: john@gmail.com so. safe or dangerous? thanks.
the way have set code out isn't how laravel should used.
for best usage of laravel need put form html views folder under own file example: form.blade.php.
you need make new controller php artisan make:controller formcontroller
i'd suggest making requests folder: php artisan make:request formrequest
within requests brand each of required html name= fields example:
public function rules() { return [ 'name' => 'required', 'email' => 'required', ]; } within routes file you'd need add:
route::post('/link', 'formcontroller@submitform'); within controller you'd do:
<?php use \app\http\requests\formrequest; public function submitform(formrequest $formrequest) { // logic go in here. firstly fetch request $fetchdata = $formrequest->get(); } this basic break down of should doing. you'd need fill logic in.
ps within html have added requests check if they've been filled you'd add like:
@if ($errors->has('name')) <span class="help-block"> <strong>{{ $errors->first('name') }}</strong> </span> @endif i hope gets on right tracks of laravel.
i'd suggest taking @ laracasts have great tutorials.
Comments
Post a Comment