I created two files (test.php & test2.php).
test.php should increase the counter in the database. Then it should just redirect to test2.php
Everything works fine, but now I set a $_SESSION and now its increasing the counter by 2. Without the session_start its working perfect, but then it doesn't set my $_SESSION.
test.php
<?php
if (!isset($_SESSION)) { session_start(); }
include_once("dbtest.php");
$id = mysqli_real_escape_string($conn, $_GET["id"]);
mysqli_query($conn, "update users set clicks = clicks + 1 where id = ".$id);
$_SESSION['test_id'] = $id;
header("Location: test2.php");
?>
test2.php
<?php
if (!isset($_SESSION)) { session_start(); }
if(isset($_SESSION['test_id'])) {
echo $_SESSION['test_id'];
}
?>
It should increase the counter by 1.