Jump to content

Please help echoing header


lingo5

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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....

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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']);

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.