What can I use to differentiate two POST requests in php

0

I'm doing a web system with php, which has a conditional deviation to check if the request is a repeated post or not, I did this to ensure I would not be giving multiple repeated inserts in the database, however it has a part of the system that needs to repeat the post request even if it is repeating, and this is not happening, anyway the questions are:

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

    
asked by anonymous 21.02.2017 / 15:14

2 answers

1

This depends a lot on the structure of your code. But an idea would be to pass a Hidden field of HTML, with a specific code. Based on this code passed through the hidden field you could allow or not repeat 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);
       }
    }
?>
    
21.02.2017 / 15:55
0

Send another parameter via post, for example executeRepeat, if it is true you execute, otherwise, it does not execute.

    
21.02.2017 / 15:16