doumeng4400 2018-11-18 22:50
浏览 31

防止重新提交表单刷新php mysqli [重复]

When I refresh form page of my admin panel then the given information insert again into the database table. Here is my code below.

<?php

if ($_SERVER["REQUEST_METHOD"]=="POST") {
    if (isset($_POST['sbtn'])) {
        $message = $obj_super_admin->save_hero_info($_POST);
    }
}




?>

and the database code is given below

<?php

require 'db_connect.php';
class Super_Admin
{
    protected $db_obj;
    public function __construct()
    {
        $this->db_obj = new DB_Connection;
    }
    public function logout()
    {
        unset($_SESSION['admin_id']);
        unset($_SESSION['admin_name']);
        $_SESSION['message'] = "You are Successfully Loged Out";
        header('Location:index.php');
    } 

    public function save_hero_info($data)
    {
        $query = "INSERT INTO title_slogan(title, slogan)" . "VALUES ('$data[title]','$data[slogan]')";
        $this->db_obj ->db_conn->query($query);
        $message="Hero information succesfully saved into database";
        return $message;

    }
}
?>

The class Super_Admin is called in the main page .

Now what can i do now ? Please Help. Thanks in advance.

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?