...

View Full Version : header(location) ?target



chippy
01-19-2007, 02:53 PM
Hi all,

I'm a bit of a newbie at php and web building

Is it at all possible using the header("Location:) redirect to target a frame on my site, specifically the main frame.

Basically I created several html pages in dreamweaver ( r1.html, r2.html, r3.html....) each page resides in its own /dir with its own index.php page as below:-



<?php
//Date & Time redirection

//Retrieve the current date/time.
$timenow=strtotime("NOW");

// Set the r1 cutoff date & time.
$r1_end=strtotime( "2007-04-05 17:35" );

//If the current date and time is before the r1 cutoff date & time.
if ($timenow <= $r1_end){

//Redirect to r1.html page.
header("Location:http://mysite.com/r1/r1.html");

}

//Else if the current date and time is after the r1 cutoff date & time.
elseif ($timenow >= $r1_end){

//Redirect to "sorry you missed it" page.
header("Location:http://mysite.com/sorry.html");
}

?>

Each of these pages ( r1.html, r2.html, r3.html.....etc.) has a dropdown menu/list box on it which has a http:// link to the index.php for each /dir.

Hope I'm making sense so far.

Now the problem I'm having is, the r1.html page opens up in the main frame no problem, but if I use its dropdown menu to select r2.html or any other page, they all open up outside of the frame in the whole window and I have to use the browser back button to get back to the site.

I have tried using the:-

<head>
<base target="main">
</head>

on each .html page but it doesn't work.

I'm sure its something really basic, but for the life of me I can't figure it out.

Any help is much appreciated

cheers

chip

neomaximus2k
01-19-2007, 05:26 PM
the header("Location: "); part of php does not accept targets, however an alternative way of doing this is to not use the header command at all (really it should only be used for redirecting not for what you want to do) so what I would do is use an include instead, thus solving the problem completly

chippy
01-20-2007, 12:55 AM
I would do is use an include instead, thus solving the problem completly

Hi neomaximus2k, thanks for your reply.

Is this what you mean?


//If the current date and time is before the r1 cutoff date & time.
if ($timenow <= $r1_end){

//Redirect to r1.html page.
include("../r1/r1.html");

}

//Else if the current date and time is after the r1 cutoff date & time.
elseif ($timenow >= $r1_end){

//Redirect to "sorry you missed it" page.
include("../sorry.html");
}

neomaximus2k
01-20-2007, 11:37 AM
Hi neomaximus2k, thanks for your reply.

Is this what you mean?


//If the current date and time is before the r1 cutoff date & time.
if ($timenow <= $r1_end){

//Redirect to r1.html page.
include("../r1/r1.html");

}

//Else if the current date and time is after the r1 cutoff date & time.
elseif ($timenow >= $r1_end){

//Redirect to "sorry you missed it" page.
include("../sorry.html");
}


Yep thats basicly it, personally i dont like using the "../" part in includes has caused me nothing but grief so I tend to set a variable called $abspath to the absolute path to the root directory of the website, that way i dont have to worry about includes.

chippy
01-21-2007, 02:01 AM
Yep thats basicly it, personally i dont like using the "../" part in includes has caused me nothing but grief so I tend to set a variable called $abspath to the absolute path to the root directory of the website, that way i dont have to worry about includes.

Thanks neomaximus2k, I will definately try your suggestion and see how I get on, I will post back here with the results.

neomaximus2k
02-04-2007, 12:13 AM
Thanks neomaximus2k, I will definately try your suggestion and see how I get on, I will post back here with the results.

This is part of the config.inc.php file i tend to use with my projects



$companyname = "Paramiliar Design Studios";
$websiteurl = "http://".$_SERVER['HTTP_HOST']."/";
$secureurl = "https://".$_SERVER['HTTP_HOST']."/";
$abspath = "/home/sites/paramiliar.net/public_html";
$adminpath = $abspath."/theadmin";


As you can see i hard code the absolute path in the $abspath variable and the others are self explanatory



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum