php redirect

This is a discussion on "php redirect" within the PHP Forum section. This forum, and the thread "php redirect are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jun 17th, 2006, 17:29
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
php redirect

could someone tell me how i can redirect this page

Code: Select all
<!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>
<script language="javascript" type="text/javascript">
function reDirect()
{
}
function openPage( form )
{
var newindex = form.months.selectedIndex
var page = form.months.options[newindex].value
if (page=="clear")
{ 
alert("Please select a month")
}
else
{
window.location = "blog.php?id=" + page
}
}
</script>
<style type="text/css">
#blogcontainer {
width:400px;
}
#imgl {
float:left;
height:100%;
}
h2 {
color:darkorange;
font-family:arial;
padding-left:5px;
}
#details {
color:gray;
font-family:arial;
font-size:9pt;
font-weight:bold;
padding-left:5px;
}
p {
font-family:arial;
padding-left:5px;
}
hr {
height:3px;
background-color:darkorange;
width:400px;
}
#rentry {
width:400px;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<TITLE>Luv-2-Cook.Com - Online Recipes, Cooking & Forums, Free Recipes</TITLE>
  <meta name="MSSmartTagsPreventParsing" content="true">
  <meta name="description" content="The best site to learn all about food and cooking, with forums, recipes and lots more.  Click here to find the latest and greatest recipes">
  <meta name="Keywords" content="low calorie and vegetarian recipes, world food and wine, a chefs help, chocolate and dessert recipes, italian food, recipes whole foods, free recipes, chocolate chip cookies, vegetarian recipes, chicken, dessert recipes, cooking light cooking recipes, italian cooking, food, italian cookery, chocolate desserts, desserts, italian cuisine, 
cooking, chef, culinary arts, beef, vegetarian, tip, culinary, tips, cookery books, cuisine" />
  <meta name="resource-type" content="document">
  <meta name="generator" content="www.e-HQ.co.uk">
  <meta http-equiv="pragma" content="no-cache">
  <meta name="revisit-after" content="15 days">
  <meta name="classification" content="Food and Beverage">
  <meta name="robots" content="ALL">
  <meta name="distribution" content="Global">
  <meta name="rating" content="Safe For Kids">
  <meta name="copyright" content="Glynn Alexander">
  <meta name="author" content="Glynn Alexander">
  <meta http-equiv="reply-to" content="Glynn Alexander">
  <meta name="language" content="english">
  <meta name="doc-type" content="Public">
  <meta name="doc-class" content="Completed,">
  <meta name="doc-rights" content="Copywritten Work,">
<style type="text/css">
<!--
body {
 background-image: url(background.gif);
}
a:link {
 color: #FFCC99;
}
a:visited {
 color: #FFCC99;
}
a:active {
 color: #FFCC99;
}
-->
</style>
<link href="style2.css" rel="stylesheet" type="text/css" />
</head>
<body onload="reDirect()">
<div align="center">
  <table width="771" height="97" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <th width="790" bgcolor="#FFFFFF" scope="col"><div align="left">
        <table width="770" height="214" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <th width="475" rowspan="8" bgcolor="#FFFFFF" scope="col"><table width="473" height="211" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <th width="19" height="226" rowspan="2" scope="col">&nbsp;</th>
                  <th width="454" height="193" scope="col"><img src="logo.gif" width="452" height="179" align="left" /></th>
                </tr>
                <tr>
                  <th height="19" scope="col">&nbsp;</th>
                </tr>
            </table>
              <div align="right"></div>
              <div align="right"></div></th>
            <th width="151" bgcolor="#FFFFFF" scope="col"><div align="left"><a href="index.html"><img src="home.jpg" width="103" height="33" border="0" /></a></div></th>
            <th width="144" bgcolor="#FFFFFF" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <th bgcolor="#FFFFFF" scope="col"><div align="left"><a href="recipes.html"><img src="free recipes.jpg" width="103" height="28" border="0" /></a></div></th>
            <th bgcolor="#FFFFFF" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <th bgcolor="#FFFFFF" scope="col"><div align="left"><a href="/Forums"><img src="forums.jpg" width="103" height="27" border="0" /></a></div></th>
            <th bgcolor="#FFFFFF" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <th bgcolor="#FFFFFF" scope="col"><div align="left"><a href="learning.html"><img src="learning.jpg" width="102" height="27" border="0" /></a></div></th>
            <th bgcolor="#FFFFFF" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <th bgcolor="#FFFFFF" scope="col"><div align="left"><a href="video.html"><img src="video.jpg" width="102" height="27" border="0" /></a></div></th>
            <th bgcolor="#FFFFFF" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <th bgcolor="#FFFFFF" scope="col"><div align="left"><a href="shop.html"><img src="shop.jpg" width="103" height="27" border="0" /></a></div></th>
            <th bgcolor="#FFFFFF" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <th bgcolor="#FFFFFF" scope="col"><div align="left"><a href="events.html"><img src="events.jpg" width="103" height="27" border="0" /></a></div></th>
            <th bgcolor="#FFFFFF" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <th bgcolor="#FFFFFF" scope="col"><div align="left"><a href="links.html"><img src="links.jpg" width="103" height="22" border="0" /></a></div></th>
            <th bgcolor="#FFFFFF" scope="col">&nbsp;</th>
          </tr>
        </table>
      </div>
        <table width="704" height="33" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <th width="704" scope="col">&nbsp;</th>
          </tr>
        </table>
        <table width="730" height="25" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <th width="238" height="25" bgcolor="#FFCC99" scope="col"><form name=form><select name="months" id="months">
   <option value="clear">Select Month...</option>
   <option value="0606">June 2006</option>
   </select> <input type="button" value="Go!" onClick="openPage( this.form )" /></form></th>
            <th width="238" bgcolor="#FFCC99" scope="col">&nbsp;</th>
            <th width="254" bgcolor="#FFCC99" scope="col"><form action="search.php?mode=results" method="post">
              <div align="left">
                <input name="search_keywords" type="text" class="post" onfocus="this.value=''" value="Search..." size="25" />
                <input class="button" name="Submit" type="submit" value="Go" />
              </div>
            </form></th>
          </tr>
        </table>
        <table width="754" height="207" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <th width="598" height="31" scope="col">&nbsp;</th>
            <th width="156" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <th height="129" scope="col"><table width="591" height="600" border="1" cellpadding="1" cellspacing="0">
              <tr>
                <th width="585" height="544" bordercolor="#FFCC99" scope="col">
    <?php
    $file = $_GET["id"] . "blog.txt";
    $fp = fopen($file,"r");
    $data = fread($fp, 100000);
    $close = fclose($fp);
    echo $data;
    ?>
    </th>
              </tr>
            </table></th>
            <th width="156" scope="col"><script type="text/javascript"><!--
google_ad_client = "pub-2317449203528081";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "FED5AF";
google_color_bg = "FFFFFF";
google_color_link = "FED5AF";
google_color_url = "FED5AF";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>&nbsp;</th>
          </tr>
          <tr>
            <th height="19" scope="col">&nbsp;</th>
            <th width="156" scope="col">&nbsp;</th>
          </tr>
        </table>
        <table width="679" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <th width="81" height="23" bgcolor="#FFCC99" scope="col"><div align="left"><a href="copyright.html"><img src="copyright.jpg" width="80" height="23" border="0" align="right" /></a></div></th>
            <th width="214" bgcolor="#FFCC99" scope="col">&nbsp;</th>
            <th width="264" bgcolor="#FFCC99" scope="col"><a href="<A href="mailto:admin@luv-2-cook.com"><img">mailto:admin@luv-2-cook.com"><img src="contact.jpg" width="48" height="24" border="0" align="left" /></a></th>
            <th width="120" bgcolor="#FFCC99" scope="col"><div align="right"><a href="terms.html"><img src="terms of use.jpg" width="103" height="23" border="0" /></a></div></th>
          </tr>
        </table>
        <p>&nbsp;</p></th>
    </tr>
  </table>
</div>
</body>
</html>
to here
Code: Select all
'Location: $month . $year . "blog.txt";
thank you
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jun 17th, 2006, 17:59
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php redirect

Do you mean that anytime anyone calls page A you want it to go to page B?

If you do, then this is best handled in the .htaccess file.

If you want to be able to redirect as a result of some processing, then that's a different issue.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jun 17th, 2006, 18:51
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: php redirect

it is basically part of a blog, it has to go througth that page to get to the latest blog

so i want it just to redirect to the latest blog automatically, so i can link my normal html pages to that page and as soon as they click on the option they will be redirected to the latest blog

example :-

link ( click ) --> that page above ( auto redirect ) --> latest blog

p.s - the latest page would be called something like 0606blog.txt ( MMYYblog.txt )
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)

Last edited by saltedm8; Jun 17th, 2006 at 19:02.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Jun 18th, 2006, 12:14
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php redirect

Have I got the right idea?

You don't want people to see the above page at all?

All that code is just a dummy effectively?

Or are you wanting the redirect to take place from within the function called by the 'Go' button?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Jun 18th, 2006, 12:18
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: php redirect

( yes, i think you have the right idea )
if possible i dont want them to see that page, but i have to be able to link to it from my normal html pages, so they are instantly re-directed to the latest blog, no 'go' button

( the whole point is so that each time i make a blog, i do not have to change the links in my html pages to go to the latest blog )

effectivly, all i want to use that page for is to re-direct to the latest blog ( not possible in html )
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)

Last edited by saltedm8; Jun 18th, 2006 at 12:28.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Jun 18th, 2006, 12:36
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php redirect

It's entirely possible in html.

You just need a refresh meta tag.

Code: Select all
<meta http-equiv="Refresh" content="0;url=http://www.domain/targetpage.html">
By setting the content="0;... there is no time delay in redirecting to the given page.

You might as well get rid of all the extra code on this page so as to maximise download speed.

You should be aware that search engines are a bit wary of redirects like this. Perhaps it's something Rob could comment more on.

The better alternative is to not have this file exist at all and redirect any calls to it through your servers .htaccess file.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Jun 18th, 2006, 12:39
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: php redirect

but that wont change to go to the latest blog automatically whenever i add a new page ( that is the problem i am trying to solve )

which is why i wanted to try to intrigrate something like this somehow

Code: Select all
'Location: $month . $year . "blog.txt";
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)

Last edited by saltedm8; Jun 18th, 2006 at 12:45.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Jun 19th, 2006, 07:54
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php redirect

Surely somewhere along the way you are going to have to tell the system where the latest blog is? It can't guess!

So for example, whenever you create a page you add the link, 'bloglink.html'.

Now you can either have an actual page 'bloglink.html' and use the meta code I posted previously that contains the link to the lastest blog which you will have to keep updated.

Or you can have an entry in your .htaccess file that effectively tells the server, whenever you get a call for 'bloglink.html' serve this page instead - 'bloglatest.html' and you keep this entry updated.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Jun 19th, 2006, 11:33
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: php redirect

Quote:
Surely somewhere along the way you are going to have to tell the system where the latest blog is? It can't guess!
i was thinking maybe it could work by date, a new blog page will be created every month, say for example on the 1st of every month, is there a way to do that ?
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Jun 19th, 2006, 11:54
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php redirect

Yes, I think we can come up with something pretty straight forward.

Going off to do the the brand new grandparent bit this afternoon so I will get back to you tomorrow when I've had time to think through the solution.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Jun 19th, 2006, 12:06
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: php redirect

( congrats ) and thank you, appreiated
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)

Last edited by saltedm8; Jun 19th, 2006 at 12:46.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Jun 20th, 2006, 18:13
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php redirect

Question - Are your blog pages standard .html pages put together by yourself or are you using some form of blog software such as Wordpress.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Jun 20th, 2006, 18:19
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: php redirect

i have - addblog.php, blog.php, add_to_blog.html, blog.txt and 0606blog.txt, all custom made - no external software, designed like that so it does not need a database

if it would be easyier to see them, just send me a private message with your email address and i will send them to you
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)

Last edited by saltedm8; Jun 20th, 2006 at 18:21.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Jun 20th, 2006, 18:30
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php redirect

I'll let you know if I think I need to see them. For the moment, what is actually created? Is each new blog page a seperate .html file stored in the same directory?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Jun 20th, 2006, 18:39
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: php redirect

each new blog page is a txt file - eg 0606blog.txt, it is inserted into blog.php, www.luv-2-cook.com/blog.php which is also the template
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)

Last edited by saltedm8; Jun 20th, 2006 at 18:51.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Jun 20th, 2006, 19:15
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php redirect

This seems to have become a two way conversation so lets close this thread and use PMs. One coming your way.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #17  
Old Jun 20th, 2006, 19:30