Solved

Redirect from CD

Posted on 2004-08-17
2
182 Views
Last Modified: 2008-03-06
Hi

My company are making a CD-ROM with a load of links to websites on it.  As the CD-ROM cannot be amended once it's been sent to our customers, we need a way of keeping the websites up-to-date.

I had the bright idea of creating a MySQL database table with two columns: 'Weblink' and 'nWeblink'.

'Weblink' would hold the current website http reference and  'nWeblink' would initially be set with nothing in it.  If for some reason one of the website dies, we would then enter a new similar website in 'nWeblink'.

What I want to do is direct a link from the CD-ROM to a PHP page on my company's website, get the PHP to check if the website is still active (i.e. there is nothing in 'nWeblink') and then go on to redirect to the correct website.

I have successfully set my RecordSet ($Recordset1) using Dreamweaver, but now I need to code the above with PHP?  

Can anyone help?

Thanks in advance
N




0
Comment
Question by:nelliott
2 Comments
 
LVL 25

Accepted Solution

by:
Squinky earned 250 total points
Comment Utility
Redirects from CD work great, and I've done it many times using a technique similar to what you're suggesting.
I'd just keep a single named link to each site and map it as necessary.
I'd create each link in your CD to point at your redirect script, using a name for the link, rather than a URL, something like:

http://www.example.com/redirect.php?weblink=home

then in your redirect script, map the redirect name to the URL via your database:

if ($result = mysql_query("SELECT * FROM redirect WHERE weblink = '{$_REQUEST['weblink']}'")) {
  if (mysql_num_rows($result) > 0) {
    $data = mysql_fetch_array($result, MYSQL_NUM);
    header("Location: {$row[0]}");
    exit;
  }
}
header('location: http://www.example.com/'); //Fail-safe: go somewhere nice if the redirect didn't work for some reason

I's very hard to make it fall back to other locations dynamically because you only get one chance to issue the redirect. The only way you can do it is to pre-validate all the sites it may go to, which is why I don't think it's worth maintaining more than one link for a given link name.

What are you building your CD-ROM in?
0
 

Author Comment

by:nelliott
Comment Utility
Works beautifully!  

Thanks for your time
N

PS.  I just work on the website and don't have anything to do with the actual build of the CD's.  Thanks again.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now