stop inserting data in the database when refreshing the page

后端 未结 10 1267
太阳男子
太阳男子 2020-12-06 02:27

I am looking for a way to stop inserting or sending data in the database when refreshing the page.

here is my code:

user_details_page.php

<         


        
10条回答
  •  自闭症患者
    2020-12-06 02:59

    We can stop it without redirect , best way to use PHP $_SESSION like this :

    if($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_SESSION['form_submit']) )
    { 
        extract($_POST);
        $sql=""INSERT INTO table (username, useremail, email) VALUES('$username','$useremail','$email')";
        $_SESSION['form_submit']='true'; 
    } 
    else
     {
        $_SESSION['form_submit']='NULL';
     }
    

提交回复
热议问题