What can I use to differentiate two POST requests in php

Asked

Viewed 101 times

0

I am making a web system with php, which has a conditional deviation to check whether the request is a repeated post or not, I did this to ensure that I would not keep giving multiple repeated Inserts in the database, however there is a part of the system that needs to let repeat the post request even if it is repeating, and this is not happening, Mfim the questions are:

How the server differentiates a POST request and How can I differentiate this post request.

2 answers

1


This depends a lot on the structure of your code. But an idea would be to pass a HTML Hidden field, with a specific code. Based on this code passed through the Hidden field you could allow or not repeated insertion;

Example:

<form method="post">
    <input type="hidden" name="tipo_insercao" value="unica"/>
    <input type="text" name="email" placeholder="Email"/>
    <input type="submit"/>
</form>

PHP would react more or less like this:

<?php
    if(isset($_POST['tipo_insercao'])){
       $tipo_insercao = $_POST['tipo_insercao'];
       $email = $_POST['email'];

       //Aqui fazemos o que for preciso com os dados. Inserir no banco?

       if($tipo_insercao=="unica"){
           unset($_POST);
       }
    }
?>

0

Sends another parameter via post, for example executing, if it is true you execute, otherwise you do not execute.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.