I want only one entry in this table. Multiple records are created when the user clicks the button several times. I can do this client-side, no problem. But wouldn’t it be safer to do it server-side. How can I wait for your help.
When I do it with javascript, the user can right click and examine and remove the code. So I want to make it server-side and secure it.
Do you think it is enough for me to do this only on the client side?
My seos table below
id|site_name |site_description | site_keywords |
1 |Fibonaccci |Site Description Here... | keyword, keyword1, keyword2 |
@extends('layouts.admin-panel.master')
@section('title', 'Fibonacci - Seo')
@section('content')
<div class="content">
<div class="page-inner">
<div class="page-header">
<h4 class="page-title">Seo</h4>
<ul class="breadcrumbs">
<li class="nav-home">
<a href="#">
<i class="flaticon-home"></i>
</a>
</li>
<li class="separator">
<i class="flaticon-right-arrow"></i>
</li>
<li class="nav-item">
<a href="#">Seo</a>
</li>
</ul>
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4 class="card-title">Seo</h4>
</div>
<div class="card-body">
<form action="{{ route('seo.store') }}" method="POST" >
@csrf
<div class="row">
<div class="col-md-12">
<div class="form-group p-0 margin-bottom-20 mt-0">
<label for="name">Site Title (Characters left: 70)<span class="text-red">*</span></label>
<input id="name" type="text" name="site_name" class="form-control" placeholder="Title must be within 70 Characters" required>
</div>
</div>
<div class="col-xl-6">
<div class="form-group p-0 margin-bottom-16 mt-0">
<label for="desc">Site Description (Characters left: 150)<span class="text-red">*</span></label>
<textarea id="desc" name="site_description" class="form-control" rows="5" placeholder="Description must be within 150 Characters" required></textarea>
</div>
</div>
<div class="col-xl-6">
<div class="form-group p-0 margin-bottom-16 mt-0">
<label for="keyword">Site Keywords (Separate with commas)<span class="text-red">*</span></label>
<textarea id="keyword" name="site_keywords" class="form-control" rows="5" placeholder="keyword1, keyword2, keyword3" required></textarea>
</div>
</div>
<div class="col-12">
<button type="submit" class="btn btn-success">Create</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
2
Answers
My solution here. I would love to find out if you have a better method.
My other solution. Is it possible to provide complete protection with this solution. For example, when the form tag is removed, the user is not able to submit it already. When it is not removed, it will always work. Say what.
You can use the ‘unique’ constraint in the form validation.
https://laravel.com/docs/6.x/validation#rule-unique