skip to Main Content

when i submit the form server give me a 403 error. when i insert special characters in textarea.

Blade file:

<form action="submit_error" method="POST">
   @csrf
   <div class="form-group">
       <label for="">Title</label>
       <input type="text" class="form-control" id="" name="title" placeholder="Write your question">
   </div>
   <div class="form-group mt-4">
       <label for="">Description</label>
       <textarea class="form-control" id="" rows="3" name="description" placeholder="Write Your problem in detail"></textarea>
   </div>
   <script src="https://cdn.ckeditor.com/4.19.1/full/ckeditor.js"></script>
   <label for="exampleFormControlTextarea1" class="form-label mt-4">What did you try?</label>
   <textarea name="err_code" placeholder="Write your code"></textarea>
   <script>
       CKEDITOR.replace( 'description' );
   </script>
   <script>
       CKEDITOR.replace( 'err_code' );
   </script>
   <div class="form-group mt-4">
        <label for="">Tag</label>
        <input type="text" class="form-control" id="" name="tag" placeholder="Add one tag about your query ex:Php">
   </div>
   <button type="submit" class="btn btn-primary mt-4">Post Error</button>

Controller Code:

public function submit_error(Request $request)
    {
        $all_data =  $request->all();
        $user_id = Auth::id();
        $user_name = User::where('id',$user_id)->value('name');
        $slug = str_slug($all_data['title']);
        
        $tag_find = DB::table('tags')->where('tags',$all_data['tag'])->exists();
        
        if($tag_find != '1'){
            $tag_find = DB::table('tags')->insert([
                'tags' => $all_data['tag']
                ]);
        }

         
        $askerror = AskError::create([
            'user_name' => $user_name,
            'title' => $all_data['title'],
            'description' => $all_data['description'],
            'err_code' => $all_data['err_code'],
            'tag' => $all_data['tag'],
            'slug' => $slug
        ]);
        

        return redirect()->route('index');
    }

when i insert special characters in textarea then i got a 403 error. so, how to solve it?

2

Answers


  1. Your form action attribute is not correct.
    Change from

    <form action="submit_error" method="POST">
    

    to

    <form action="{{ route('submit_error') }}" method="POST">
    

    Also make sure you have added the route name on routes/web.php file like this sample.

    Route::post('submit_error', 'YourController@submit_error')->name('submit_error');
    
    Login or Signup to reply.
  2. Which Input you need to allow special characters, then just add this parameter to it

    CKEDITOR.replace( 'description', {
        allowedContent: '!@<>{}%$'
    });
    

    or you can use it in config

    config.extraAllowedContent
    

    Read extraAllowedContent() and allowedContent()

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search