if a query what exist http://localhost/page.php?pid=first-page is open me, it is work, but if i write http://localhost/page.php?pid=second-page and second-page doesnt exist it still open a page and give this error because doesnt find...
I understand why give me this error, but i dont know how to relocation the url if a some write a wrong query
session_start();
require "conx.php";
// Determine which page ID to use in our query below ---------------------------------------------------------------------------------------
if(isset($_GET['pid'])){
    $pageid = preg_replace('[^a-z0-9_]', '', $_GET['pid']);
    }   
    // $tag is now santized and ready for database queries here
// Query the body section for the proper page
$stmt = $con->prepare('SELECT pagebody FROM pages WHERE linklabel = ?');
$stmt->bind_param('s', $pageid);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_array()) {
    // do something with $row
    $body = $row["pagebody"];   
}
so i how i can relocation the url address if a the query doesnt exist??
 
    