Log in

View Full Version : Redirecting automatically



fileserverdirect
02-17-2007, 09:40 PM
Hi,
I am creating a website (my username says it all) but I hit a stump.
The User Logs in to his or her account by typing in the main accounts' name and their username. this page brings you to a password (ssl protected) page. but when the "Master Accounts" name and their name are sent... the address bar will say somthing like:
www.thesite.com/login.php?master_account=yodog1;account=yocat2
and I create the password page manually for each account. So the Question really is how can I Take the infromation from the address bar and have the page redirect to a certain one and if invalid display a custom error message... not a HTTP 404 Not Found Error. I Have seen websites do this before... so I know It Can be done. Please Help,

-- File Serverdirect.net

Tristan S.S.
02-17-2007, 10:12 PM
try this for luck...




<?

if($_GET['master_account'] =="yodog1"){
if($_GET['account'] =="yocat2"){

header("Location: http://www.example.com/securepage.php")
exit;

}else{

header("Location: http://www.example.com/custommessage.php")
exit;

}
}else{

header("Location: http://www.example.com/custommessage.php")
exit;

}

?>



And remeber to place it at the top of your page above any DTD's and <html> tags.

Good Luck

fileserverdirect
02-17-2007, 10:36 PM
I just Tryed that and uploaded it. It still didn't work. And how can you add more than one "master account" and account. I even tryed coping the code and re-pasting it below... but reailized that the script would have had already sent to the error page before it got to check if it was another acount besides yodog1.(If it worked)

Whats going on here?

Tristan S.S.
02-17-2007, 11:27 PM
Hmmm...

the $_GET['master_account'] is pulling yodog1 from the URL and it has to be there same with $_GET['account']. Have you replaced the files /securepage.php and /custommessage.php with you own and changed the URL inside the tag?

If you want more than one account you should probably use mysql

fileserverdirect
02-17-2007, 11:56 PM
Yes I Have replaced the right page names and created them and uploaded all of them, anyway when you use My SQL you would need all three colums. Master Account, User, Password. and then import them to the document. Now I am starting to get it. This also means that I can have the user create the account without me doing anything. One Problem, My current Hosting Plan doesn't support My SQL.... So is there any other File-Based way I can have mulitple accounts but stil do the same thing as a database?

thetestingsite
02-18-2007, 01:31 AM
You could utilize SQLite (not sure of the right name, but pretty sure this is it), which is a flat file database. Not very secure, but this is one of the only alternatives unless your host supports some other type of database system.

Tristan S.S.
02-18-2007, 02:01 AM
Here try one these sites a simple google search picks up:

- http://www.freesql.org/
- http://www.free-webhosts.com/free-mysql-database.php (search for one with MySQL)
- http://free-mysql.bizhostnet.com/step1.html

Then just link to one of them through php on you webpage.

That should be enough. If you need help setting up one just ask!

Cya

thetestingsite
02-18-2007, 02:12 AM
After looking at those site posted above; if you still need a free MySQL database, let me know and I can set one up for you on one of the servers I run.

fileserverdirect
02-19-2007, 09:07 PM
(Sorry for the late post)
Thank you for the support with the my sql stuff... but maybe somthing a little simpler... instead on of this whole database troubles. For now I need somthing like if the url was www.mysite.com/index.html and on that page there was a form that had an action of redirect.php?url=yodog1.html and a submit button, like this:

<form action=redirect.php?url=yodog1.html method=POST>
<input type=submit value="Continue">
</form>
The redirect page would read the data (yodog1.html) and send it there. Thats it. I thought it would be simple... but im doing somthing worng. Here's what the php code looks like:

<?php

$url =($_GET['url'])

header($url);

?>
"It Couldn't get any easier"
(Shows what I know).

Can someone tell me what should be the php code?

Tristan S.S.
02-21-2007, 12:16 AM
Ok I see what you mean.

Here you go, you had it right but you were just missing a few things:




<?php

$URL = "".$_GET["url"]."";
header("Location: $URL");

?>



Do you understand or do you want me to go throught it with you?