Redirect to another page
Posted by Chris_Isaac (Chris Isaac), 11 February 2004Hi
The code should print out a list of towns(hyperlinked to files of the same name) then redirect the user to that page if it exists, or print a warning message if it doesn't.
The following code works fine except for the redirect bit, I've set the header info at the top, with a if statement to trigger it off. It does print the messages, but then doesn't redirect.
Can you see anything obvious I've done wrong?
Posted by admin (Graham Ellis), 11 February 2004I'm confused.
"Redirect" goes in the header, and can only go to one page .... you are showing a series of links that will be followed when you select a link.
Do you want the page to be automatically replaced by another after a certain number of seconds, or so you want your users to click on a piece of text to jump to another page of their choice?
You can't have it offering a big list of pages then move on to one automatically without any user input, as it won't know which one to move on to!
P.S. With "localhost" and "C:" paths all over the place, your code is pretty unportable .... suggest you leave the host name out of the URL and you use relative paths!
Posted by Chris_Isaac (Chris Isaac), 11 February 2004Your confused... I'm confused and I wrote it..
Sorry, the header to redirect should be a varible $town (generated by the town hyperlinks below), not a fixed place as above.
Basically what I would like to happen is a list of towns is generated, eg:
Each of the above is a hyperlink, if pressed, will go to the town page of that name, eg, newport.php4 if that page exists, or print an error message if it doesn't (actually I want it to generate the page automatically, but will work this bit out next).
Hope this clears things a bit.
Also note taken about the portability, will address this to.
Posted by admin (Graham Ellis), 12 February 2004I'm guessing that the links are appearing but don't follow properly? I'm almost certain it's failing because of your link to "localhost" which means that your web visitor will be directed to a script on HIS OWN COMPUTER when he clicks the link ...
Suggestion for testing. Generate the page with the problem links and use your browser's view source to examine what you've actually generated. Try typing the URLs shown in the source into your location box and see what's wrong with them that way - a sort of debug mode. You can play with the URL in the location box until you get the page you want, then transfer the changes you had to make back to your script.
Posted by Chris_Isaac (Chris Isaac), 12 February 2004The hyper links are working, if for example you click on newport, it does print out the correct message depending if Newport exists or not, if it exists, it prints out "yes blah blah Newport exists" then "should redirect" as in the following bit of code:
but then doesn't go anywhere. Could the problem be in $redisrect=2; or perhaps the following :
I'll look at the source as well later to see if I can see anything there.
Posted by Chris_Isaac (Chris Isaac), 13 February 2004As Dora the Explorer would say "I did it!!"
I had my test statement in the wrong place, I needed it at the top just before the header statement.
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho