当我刷新管理面板的表单页面时,给定的信息再次插入数据库表中。这是下面的代码。
<?php
if ($_SERVER["REQUEST_METHOD"]=="POST") {
if (isset($_POST['sbtn'])) {
$message = $obj_super_admin->save_hero_info($_POST);
}
}
?>
,下面给出了数据库代码
<?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;
}
}
?>
在主页中调用Super_Admin类。
现在我该怎么办?请帮忙。 提前致谢。