lingo5 Posted May 22, 2012 Share Posted May 22, 2012 Hi, I have a link on my page like so: <a href="index.php?search=true"><img src="img/buscado_palabr_tab_off.png" width="147" height="30" border="0" /></a> I need my index.php page to display header.php by default or header_2.php when the user clicks on the link above. This is my index.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <?php if isset($_GET['search']); { echo 'header_2.php'; } else { echo 'header.php'; } ?> <body> </body> </html> ...this code is not working....what am I doing wrong? Many thanks Quote Link to comment Share on other sites More sharing options...
floridaflatlander Posted May 22, 2012 Share Posted May 22, 2012 I would think your file would need some type of Get statement for search and if it was true echo the new header Also where is your doc types, in the file above and in the headers? You're starting your header then calling headers. Quote Link to comment Share on other sites More sharing options...
.josh Posted May 22, 2012 Share Posted May 22, 2012 echo just outputs literal strings (or parsed variables if in double quote). If you are wanting to execute/output the content of those scripts then you need to use include or require instead of echo. Quote Link to comment Share on other sites More sharing options...
.josh Posted May 22, 2012 Share Posted May 22, 2012 I would think your file would need some type of Get statement for search and if it was true echo the new header Also where is your doc types, in the file above and in the headers? You're starting your header then calling headers. I have a sneaking suspicion when OP refers to "header" he is talking about html content(like different top of the page menu/links), not http request/response headers. Quote Link to comment Share on other sites More sharing options...
lingo5 Posted May 22, 2012 Author Share Posted May 22, 2012 yes that's right...I'm trying to echo a different top of page Quote Link to comment Share on other sites More sharing options...
lingo5 Posted May 22, 2012 Author Share Posted May 22, 2012 I would think your file would need some type of Get statement for search and if it was true echo the new header Also where is your doc types, in the file above and in the headers? You're starting your header then calling headers. I have a sneaking suspicion when OP refers to "header" he is talking about html content(like different top of the page menu/links), not http request/response headers. I have tried this <?php if isset($_GET['search']); { require_once('header_2.php'); } else { require_once('header.php'); } ?> but nothing.... Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 22, 2012 Share Posted May 22, 2012 Do you have error reporting turned on? The syntax is: if(isset($_GET['search'])) { require_once('header_2.php'); } else { require_once('header.php'); } So your code should generate at least one error. Quote Link to comment Share on other sites More sharing options...
lingo5 Posted May 22, 2012 Author Share Posted May 22, 2012 I would think your file would need some type of Get statement for search and if it was true echo the new header Also where is your doc types, in the file above and in the headers? You're starting your header then calling headers. I am doing that here <a href="index.php?search=true"><img src="img/buscado_palabr_tab_off.png" width="147" height="30" border="0" /></a> Quote Link to comment Share on other sites More sharing options...
lingo5 Posted May 22, 2012 Author Share Posted May 22, 2012 I would think your file would need some type of Get statement for search and if it was true echo the new header Also where is your doc types, in the file above and in the headers? You're starting your header then calling headers. I am doing that here <a href="index.php?search=true"><img src="img/buscado_palabr_tab_off.png" width="147" height="30" border="0" /></a> This is the error I get Parse error: parse error, expecting `'('' in C:\wamp\www\mysite\index.php on line 9 being line 9 this: isset($_GET['search']); Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 22, 2012 Share Posted May 22, 2012 Do you have error reporting turned on? The syntax is: if(isset($_GET['search'])) { require_once('header_2.php'); } else { require_once('header.php'); } So your code should generate at least one error. Quote Link to comment Share on other sites More sharing options...
lingo5 Posted May 22, 2012 Author Share Posted May 22, 2012 Thanks Jesirose !!!! that works perfect. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.