This question already has an answer here:
- PHP Inserting Duplicates In DB 1 answer
- Reference - What does this error mean in PHP? 34 answers
- How to fix “Headers already sent” error in PHP 11 answers
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>