I don’t see any html form element in there. Is that actually on the page and not included in your code snippet?
I’m also curious why you are using a form for this, rather than just a list of links.
Change
header('Location: $row[Page]');
To
$page = $row['Page']; die('Redirect to: ' . $page);
header("Location: $page");
exit();
The die statement will confirm that you are getting the url correctly. I just kind of scanned the other code. I suspect you may have other issues as well. Consider adding die statements to help trace the code. Then remove the die.
Note the double quotes in the header function. Single quotes do not cause variables to be expanded. Makes a big difference. I also broke out $page to its own variable as using arrays inside of strings has their own rules which I forget at the moment.
The exit following the header is important as well. Once you redirect, your program is done. An explicit exit make it clear.
You do understand that when the browser encounters a Location header (aka redirect) the browser stops processing the current page and moves to whatever page the location tells it to. By definition, there is never anything after a redirect and hence there is nothing to disappear.
OK, I did find it this time (after scrolling down) and can confirm that the form element is there…
…but; it is not alone.
There are two search forms, and both have the same submit buttons named “go”.
so where you have this condition for the search by title:-
if(isset($_POST['go'])) {...}
How does it distinguish between “go” from the title form or “go” from the date form?
And I’m speculating (having not seen all the source php code) that you may have that same condition repeated again at the date search form. Now that’s going to confuse things.
You need to identify which form you are dealing with.
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST['Title'])) {
// Do stuff for the title search
}
elseif(isset($_POST['Date'])) {
// Do stuff for the date search
}
}
yes i know what you mean
but with this script what happens is it is not redirecting, stays on the same page… under form is PRINTED redirect to: angry.php and the rest of the page is not visible… so header (location) is not working
It won’t do.
A header cannot come after any html output.
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. http://php.net/manual/en/function.header.php
You must put your form processing at the beginning of the page/script.
Or go the whole way to doing things properly and separate your php processing from your html altogether.
If you still want to go with the form method. The page could start something like this.
<?php // This is line 1 of the document, there is nothing before this.
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST['Title'])) {
// Do stuff for the title search
}
elseif(isset($_POST['Date'])) {
// Do stuff for the date search
}
}
// get stuff from the database ready for making your lists further down.
// Now the processing bit is out of the way, you can start printing html
?>
<!DOCTYPE html>
<html>
<head>
ect...
as i said im beginner and it is college project…we have booking form with drop down…i only wanted do extra drop down with search…never actually thought about list of links…which seems good idea
thanks