H! to all members of DP if path and id is'nt valid then how to redirect a page to index.php <?php echo "<br>"; if ($_GET['id']) { $id = $_GET['id']; } else { die ("No ID Selected"); } echo "<body bgcolor='#ffffff'>"; echo "<table border='0' bgcolor='ffffff'>"; echo "<tr><td>"; echo "<tr><td>"; echo "<tr><title> $site</title><td>"; echo "<tr><td>"; echo "<img src='./$path" . $id . "'>"; ?> tell me wht i've to put here to redirect user to index.php :- sorry for my bad grammar
here is a bit of code i put to double check if a user is logged in if (!isset($_SESSION['username'])){ header("Location: login.php"); } the header works everytime for me. Are you getting headers already sent error? if thats the case you need your redirect towards the top of the page.
Try this: <?php # take away this <br> # echo "<br>"; if ($_GET['id']) { $id = $_GET['id']; } else { # I guess you want to redirect here header("Location: http://www.mydomain.com/redirect_page"); #die ("No ID Selected"); } ... ?> PHP: HTH, cheers
It doesn't work because you have "echo "<br>";" before it. For the header function to work with that redirect you need to have no html outputted prior to it being used.