Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Redirect from CD

Posted on 2004-08-17
2
Medium Priority
?
237 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 1000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

916 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