Good day!

So, we are talking about the payment system (for personal needs). The encrypted $ _GET is sent to the "success" page with parameters, I compare the parameters, if everything is fine, I save it to the database, only it saves it twice, why can this happen?

In short, the code is approximately as follows:

if( $params['status'] == 1){ $email = $params['email']; $link = mysqli_connect("localhost", "xxx", "xxx", "xxx"); $insert = 'INSERT INTO xxx (email) VALUES ("'.$email.'")'; $query = mysqli_query($link, $insert) or die(mysqli_error($link)); } 

How can I check if the data went to not send twice? Thank!

    1 answer 1

    Use PDO

     $link = new PDO("mysql:host=$db_host;port=$db_port;dbname=$db_database", $db_user, $db_pass); $link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $link->exec("set names utf8"); $stmt = $link->prepare("INSERT INTO xxx (`email`) VALUES (:email)"); $stmt->bindValue(':email', $email); $stmt->execute(); 
    • Yes, I forgot to write that, along with saving to the database, a mail is being sent ($ to, $ subject, $ message, $ headers); and also twice - Alexander Reizan
    • @Alexander Reydzan would have a look at the script. On the vskidku only we can say that somewhere the method is called twice for some reason. You can try to remove the status parameter from the database and then the check will not pass the second time. But it's better to find out exactly what causes it - Almightily
    • Suppose I restart the page, it will also send the data .. basically the question is how to check whether they have already been sent so as not to duplicate the dispatch - Alexander Reizan
    • @Alexander Reydzan make a request to this table via this email. If there is - do not insert. I propose such a test - Almightily
    • Okay thank you! - Alexander Reizan