(1/1) TokenMismatchException in VerifyCsrfToken.php (line 68) Error when using POST - http-post

I have created a contact Form using Laravel 5.4 which works fine when I test on localhost(sends an email to my inbox), when I test on a live server(Hostgator), I get: (1/1) TokenMismatchException in VerifyCsrfToken.php (line 68) after pressing the Submit button.I have added a csrf field on the form but the problem persists
<form action= "{{ url('contact') }}" method="POST" class="contact-form" data-parsley-validate =''>
{{ csrf_field() }}
<input type="text" name="name" placeholder="Full Name..." class="input" minlength = "13" required>
<input type="text" name="phone" placeholder="Phone Number..." class="input" type="integer" required>
<input type="email" name="email" placeholder="Email Address..." class="input" required>
<textarea name="message" class="input" minlength="100" rows="10" required> </textarea>
<input type="submit" value="Submit">
</form>

i had the same problem with laravel 5.2 two day ago and my solution was the next:
add this after whithout spaces inside the {{ }} and work fine

Related

Ipay88 payment integration in flutter app through webview

Any one has experience implementing payment gateway iPay88 for flutter through webview?
The same code working in website and showing the ipay88 payment form but when using that same code in flutter app so not showing the payment page and redirecting to responseUrl directly.
Any help will be appreciated.
Code of webview is:
<form method="post" name="ePayment" id="ePayment"
action="https://payment.ipay88.com.my/ePayment/entry.asp">
<input type="text" name="MerchantKey" value="{{ env('IPAY88_MERCHANT_KEY') }}">
<input type="text" name="MerchantCode" value="{{ env('IPAY88_MERCHANT_CODE') }}">
<input type="text" name="PaymentId" value="">
<input type="text" name="RefNo" value="{{ $order->code }}">
<input type="text" name="Amount" value="{{ $amount }}">
<input type="text" name="Currency" value="MYR">
<input type="text" name="ProdDesc" value="Order #{{ $order->code }}">
<input type="text" name="UserName" value="{{ $user->name }}">
<input type="text" name="UserEmail" value="{{ $user->email }}">
<input type="text" name="UserContact" value="{{ $user->phone }}">
<input type="text" name="Remark" value="">
<input type="text" name="Lang" value="UTF-8">
<input type="text" name="SignatureType" value="SHA256">
<input type="text" name="Signature" value="{{ $hash }}">
<input type="text" name="ResponseURL" value="{{ url('api/v2/api/ipay88/response') }}">
<input type="text" name="BackendURL" value="{{ url('api/v2/api/ipay88/backend') }}">
<input type="submit" value="Proceed with Payment" id="checkout-button" name="Submit">
</form>
Ipay88 redirects to the responseUrl instead of payment page.

I can't get back()->withInput() to work, the documentation seems a little sparse on how it should work

I'm using blade templates and this is how my form looks:
<form action="{{ route("user-sessions.store") }}" method="POST">
#csrf
<div class="form-group">
<label for="e-mail">E-mail Address</label>
<input name="email_address" class="form-control" type="email" />
</div>
<div class="form-group">
<label for="password">Password</label>
<input name="password" class="form-control" type="password" />
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" />
</div>
</form>
Does back()->withInput() only work with {{ Form::open() }}? If so, the 7.x documentation doesn't say that it seems. I would think if you need a 3rd party library to get this to work, the documentation should say so. If that's not the issue, then what am I doing wrong?
I'm using Laravel 7.x.
if you use html collective, it automatically puts old values in form inputs. But when use pure html to create form inputs you have to use old method for input values. like this:
<form action="{{ route("user-sessions.store") }}" method="POST">
#csrf
<div class="form-group">
<label for="e-mail">E-mail Address</label>
<input name="email_address" class="form-control" type="email" value="{{old('email_address')}}"/>
</div>
<div class="form-group">
<label for="password">Password</label>
<input name="password" class="form-control" type="password" value="{{old('password')}}"/>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" />
</div>
</form>

How to upload the pdf or doc file in laravel

I am trying to upload the pdf or doc file on the website made up in laravel. This is my blade page.
<form action="{{ route('file.upload.post') }}" method="POST" enctype="multipart/form-data">
#csrf
<div class="row">
<input type="text" class="form-control-file" name="title" id="title" aria-
describedby="fileHelp", placeholder="title">
<input type="text" class="form-control-file" name="firstName" id="firstName" aria-
describedby="fileHelp", placeholder="First Name">
<input type="text" class="form-control-file" name="lastName" id="lastName" aria-describedby="fileHelp", placeholder="Last Name">
<input type="text" class="form-control-file" name="isReviewed" id="isReviewed" aria-describedby="fileHelp", placeholder="isReviewed">
<div class="col-md-6">
<input type="file" name="paper" class="form-control">
</div>
<div class="col-md-6">
<button type="submit" class="btn btn-success">Upload</button>
</div>
</div>
</form>
This is my controller
public function fileUploadPost(Request $request)
{
$request->validate([
'firstName'=>'required',
'lastName'=>'required',
'isReviewed'=>'required',
'paper' => 'required|mimes:pdf,xlx,csv|max:2048',
]);
$Submission= new Submission;
$Submission->title= $request['title'];
$Submission->first_name= $request['firstName'];
$Submission->last_name= $request['lastName'];
$Submission->isReviewed= $request['isReviewed'];
$fileName= time().'.'.$request->paper->extension();
$old_path = Request::file('paper')->getPathName(); Storage::disk('Paper')->move($old_path,
public_path($fileName));
$Submission->save();
return back()
->with('success','You have successfully upload file.')
->with('file',$fileName);
}
I am getting an error saying that
Non-static method Illuminate\Http\Request::file() should not be called statically
to fix this i
use Illuminate\Support\Facades\Request
instead of
use Illuminate\Http\Request;
but then I get an error saying I cannot use validation. Any kind of help is appreciated.
You don't need to use the facade for this. You can still use the standard Illuminate\Http\Request class.
To get the file, you should use:
$request->file('paper')
rather than
Request::file('paper')

Login not working with VueJS and Laravel

I am working on a login for my website. I added my form below. I activated the login route with Auth::routes();. With php artisan route:list I can see my route as well. But the problem is that every time I try to login, the login page just refreshes. How can I find out what is going wrong, is there a way to get a response from my post request in order to get some debug info? Any help is welcome!
<div class="main-div">
<div class="panel">
<h2>Hello</h2>
</div>
<form id="Login" role="form" method="POST" action="/login">
<input type="hidden" name="_token" :value="csrf_token">
<div class="form-group">
<input type="email" class="form-control" id="email" placeholder="Email Address">
</div>
<div class="form-group">
<input type="password" class="form-control" id="password" placeholder="Password">
</div>
<div class="forgot">
Forgot password?
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
</div>

Submitting form action using javascript codeigniter

i have error for submitting form using javascript. the error said unknown column array. what is wrong with my array or maybe on my javascript.
this is my sample code.
<form action="">
<input type="text" name="name">
<input type="text" name="age">
<input type="button"onClick="this.form.action='<?php echo site_url('core')?>/'+'add_name';this.form.submit();" value="new"/>
</form>
WORKING WITHOUT JS
Try this:
<?php
$frmAttrs = array("id"=>"addFrm");
echo form_open('core/add_name', $frmAttrs);
?>
<input type="text" name="name">
<input type="text" name="age">
<!-- <input type="button" onClick="this.form.action='<?php //echo site_url('core/')?>'+'add_name';this.form.submit();" value="new"/> -->
<input type="button" id="submitFrm" onClick="this.form.submit();" value="new" />
</form>

Resources