Results 1 to 10 of 10

Thread: Redirecting automatically

  1. #1
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Question Redirecting automatically

    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:
    http://www.thesite.com/login.php?mas...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

  2. #2
    Join Date
    Nov 2006
    Location
    90 miles north of Las Vegas
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    try this for luck...

    Code:
    <?
    
    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

  3. #3
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    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?
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  4. #4
    Join Date
    Nov 2006
    Location
    90 miles north of Las Vegas
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  5. #5
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    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?
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    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.

  7. #7
    Join Date
    Nov 2006
    Location
    90 miles north of Las Vegas
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    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.

  9. #9
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    (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:
    Code:
    <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 Code:
    <?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?
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  10. #10
    Join Date
    Nov 2006
    Location
    90 miles north of Las Vegas
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok I see what you mean.

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

    Code:
    <?php
    
    $URL = "".$_GET["url"]."";
    header("Location: $URL");
    
    ?>
    Do you understand or do you want me to go throught it with you?
    Last edited by Tristan S.S.; 02-21-2007 at 12:16 AM. Reason: typo

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •