-1
Hello I have a website and I use this following form this script to register projects, but you need a secure form, because if I go in inspecting element on my page and change the value of my option that was administrative support for c* it will save in my db as c* I wish that value had no way to edit and tbm needed something for anti Injection, spam and CSRF or XSRF, but I don’t know how to implement it because I’m very lay in PHP, if anyone can help with any hint anything or a script that protects me from all this thank you
<?php
if(count($_POST)>0) {
require_once("conexao.php");
$sql = "INSERT INTO classificados (titulo, categoria, valor) VALUES ('" . $_POST["titulo"] . "','" . $_POST["categoria"] . "','" . $_POST["valor"] . "')";
mysqli_query($conn,$sql);
$current_id = mysqli_insert_id($conn);
if(!empty($current_id)) {
$message = "New User Added Successfully";
}
}
?>
A part of my form
<form name="frmUser" method="post" action="">
<div class="col-md-4 col-sm-12 search-col">
<div class="input-group-addon search-category-container">
<label class="styled-select">
<select required="" class="dropdown-product selectpicker" name="categoria">
<option value="">Todas Categorias</option>
<option class="subitem" value="IT & Programacao"> IT & Programação</option>
<option value="Design e Multimedia"> Design e Multimedia</option>
<option value="Tradução e Conteúdos"> Tradução e Conteúdos</option>
<option value="Marketing e vendas"> Marketing e vendas</option>
<option value="Suporte administrativo"> Suporte administrativo</option>
<option value="Finanças de Administração"> Finanças de Administração</option>
<option value="Engenharia e Manufafuta"> Engenharia e Manufafuta</option>
<option value="Legal"> Legal</option>
</select></label>
</div>
</div>
If you are very layy in PHP as you said in the question, and really need a safe form for real use, it would be the case to hire a programmer, which runs a bit of the site scope. A simple "hint" will not go anywhere near solving your problem. Now, while you’re learning, you can ask specific questions about specific parts, and as you solve each step, you can open up new questions, but always describe the problem in detail. Remembering that you can always [Dit] your post to complement (as long as it does not invalidate existing responses).
– Bacco
In the meantime, you can search here on the SQL Injection + PHP to pick up some examples of what should (and should not) do, and also about Validation + Form, Passwords + Secure etc..
– Bacco
Oops, thank you so much for the tip and help
– Caio Salchesttes