Thanks a lot
php help
Started by
amunra
, Dec 31 2005 01:15 AM
#1
Posted 31 December 2005 - 01:15 AM
Thanks a lot
#2
Posted 31 December 2005 - 05:40 AM
Put this at the start of your PHP script:
header( "Location:index.php?act=blablabla");
#3
Posted 31 December 2005 - 05:57 AM
sorry that would actually recurse the page. Try this:
if (!isset($_GET["act"])) header("Location:index.php?act=blablabla");
#4
Posted 31 December 2005 - 11:29 AM
Cool, what else do I need to do? Do I need to add seperate pages? What I am trying to do is make a redirect page named redir.php. Then I need to add the redirect script to that page to transfer it. ie:msn
redir.php?act=redir&id=msn
for instance.
Thanks
redir.php?act=redir&id=msn
for instance.
Thanks
#5
Posted 31 December 2005 - 11:43 AM
Um, I am not sure what you are trying to achieve. Isn't is simpler to just add a hyperlink in HTML?
If this is not the case, please describe the situation and we'll see what can be done.
If this is not the case, please describe the situation and we'll see what can be done.
#6
Posted 31 December 2005 - 02:46 PM
What I need to do is make a single page called redir.php. Then I need to add url redirects to that page that link to outside pages.
Any other ideas?
Thanks
<? header("Location: http://www.msn.com"); ?>is an example of what I use as a redirect code. I need to place several of these into redir.php and be able to choose which one I want via the address bar. I have tried this for the redirect code
$msn = header("Location: http://www.msn.com"); ?>and typed this ini the address bar
redir.php?$msnBut nothing happens.
Any other ideas?
Thanks
#7
Posted 31 December 2005 - 02:53 PM
Well it seems very strange why not use <A> in HTML, but what you want is this:
add more branches to the switch and you will get more redirects possible. And don't forget to break
<?php switch ($_GET["act"]) { case "msn": header("Location: http://www.msn.com"); break; case "yahoo": header("Location :http://www.yahoo.com"); break; } ?>
add more branches to the switch and you will get more redirects possible. And don't forget to break
Edited by Hai Mac, 31 December 2005 - 03:04 PM.
#8
Posted 31 December 2005 - 02:57 PM
Ok I just tried it and all it did is print the code on the screen. what would I type in the address bar to use this?
redir.php?act=msn
mabe
Thanks
redir.php?act=msn
mabe
Thanks
#9
Posted 31 December 2005 - 03:04 PM
Sorry, messed it up a bit. Now it should work
#10
Posted 31 December 2005 - 03:09 PM
SWEET it works, now I am going to add some more links to test. THANKS A LOT
#11
Posted 31 December 2005 - 03:43 PM
Lets see if I can make a lesson on this.
To make a php redirect page follow these directions.
1. Open notepad and enter the following code
Now to break down the code
Now you can save the file as anything you want, but make shure you include the .php at the end of the file name or it will not work. To link to this page from another, like you index.php page you could use this code to go to google as long as this redirect page is in the same directory
If anything here is incorect please let me know so I can update this.
Thanks again Hai Mac!
To make a php redirect page follow these directions.
1. Open notepad and enter the following code
<?php switch ($_GET["act"]) { case "[color=#3333FF]google[/color]": header("Location: [color=#FF0000]http://www.google.com[/color]"); break; } ?>The text in blue is what you will need to type in the address bar after the ?act=, for mine I used a number, but you can use any name you want. for this redirection script you will need to type name of your file.php?act=google to use the google redirection. You can change the text in red to any url you want.
Now to break down the code
<?phpStarts the php script
switch ($_GET["act"])means it will use the GET method to check if the ?act= is in the address bar
{starts the main redirect code
case "google":Specifies what you need to type after the ?act=. It can be anything you want.
header(Location:http://www.google.com");Specifies where the page should send the user after the ?act=google is entered in the address bar.
break;I do not yet know what this means.When i do I will update this. If someone knows let me know
}Ends the main redirect code
?>Ends the php script
Now you can save the file as anything you want, but make shure you include the .php at the end of the file name or it will not work. To link to this page from another, like you index.php page you could use this code to go to google as long as this redirect page is in the same directory
<a href=name of your redirect page.php?act=googleSave it and test it. I have found that testing the scripts is a very important part of the scripting process. I created a special folder called test that I do this in.
If anything here is incorect please let me know so I can update this.
Thanks again Hai Mac!
#12
Posted 31 December 2005 - 03:51 PM
The first part is good, but few amendments: switch tells PHP something like look at this variable and tell me what it contains. In case it contains google redirect me to blah blah. break tells PHP to get out to the end of the switch that is to }. Otherwise PHP will just redirect to all pages mentioned in the rest of the code.
And that's all folks
And that's all folks
Edited by Hai Mac, 31 December 2005 - 03:54 PM.
#13
Posted 31 December 2005 - 03:54 PM
Cool did not know that. Check out my other script lesson, its on a scroling news ticker. I will update the post when I get time.
Similar Topics
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users