I have a table where one of the attribute is version.
The table name is versions.
I want to redirect users to a default page if the URL parameter also called version is NULL or not present, and if the version value is not in my table.
So far I've this. It does not work.
$stonevar = isset($_GET['version']) ? $_GET['version'] : NULL;
if (empty($stonevar)) {
header("Location: index.php?version=default");
}
$id = $_GET['version'];
$result = $db->query("SELECT * FROM `versions` WHERE version='$id'");
while ($row = $result->fetch_assoc()) {
$varex = $row['version'];
}
if ($varex == NULL) {
header("Location: index.php?default");
}