Solved

Redirect from CD

Posted on 2004-08-17
2
205 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:
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Move wordpress site 3 41
Testing a string condition in PHP 6 24
error log using ftp 7 41
Get a subdirectory name from a url 5 16
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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.

831 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