check(); $sql = new DgSQL(); $pid = trim($_GET['pid']); $query = 'select PlanNumber, PlanBaseNumber, PlanName from PlanMaster where PlanID=:pid'; $data = array(':pid'=>$pid); $results = $sql->query($query, $data); if(empty($results[0]['PlanNumber'])) { header('Location: /index.php', true, 301); } else { $location = '/house-plan/' . $results[0]['PlanNumber']; if (!empty($results[0]['PlanName'])) { $location .= '/the-' . str_replace(' ','-',strtolower($results[0]['PlanName'])); } header('Location: '. $location, true, 301); }