Solved

Redirect from CD

Posted on 2004-08-17
2
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Accepted Solution

by:
Marcus Bointon earned 250 total points
ID: 11822446
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
ID: 11829281
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

751 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