Solved

Redirect from CD

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

623 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