Page 1 of 1

login script question

Posted: Sat Jan 16, 2010 6:29 pm
by rapid3642
hey guys this is really embarrassing but for some reason im not able to make the script when logging out go back to the home page it wants to go back to the login.php script and i messed around with it and nothing.

original login.php script

Code: Select all

<?php // login.php :: Handles user logins and logouts.

include("lib.php");
if (isset($_GET["do"])) { $do = $_GET["do"]; } else { $do = ""; }

switch($do) {
    case "logout":
        logout();
        break;
    default:
        login();
}

function login() {
    
    $controlrow = dorow(doquery("SELECT * FROM <<control>> WHERE id='1' LIMIT 1"));

    if (isset($_POST["submit"])) {
        
        // Setup.
        include("config.php");
        extract($_POST);
        $query = doquery("SELECT * FROM <<accounts>> WHERE username='$username' LIMIT 1");
        $row = dorow($query);
        
        // Errors.
        if ($row == false) { err("Invalid username. Please <a href=\"index.php\">go back</a> and try again.", false, false); }
        if ($row["password"] != md5($password)) { err("Invalid password. Please <a href=\"index.php\">go back</a> and try again.", false, false); }
        if ($row["verifycode"] != 1) { err("You have not yet verified your account. Please click the link found in your Account Verification email before continuing. If you never received the email, please check your spam filter settings or contact the game administrator for further assistance.", false, false); }
        
        // Finish.
        $newcookie = $row["id"] . " " . $username . " " . md5($row["password"] . "--" . $dbsettings["secretword"]);
        if (isset($remember)) { $expiretime = time()+31536000; $newcookie .= " 1"; } else { $expiretime = 0; $newcookie .= " 0"; }
        setcookie($controlrow["cookiename"], $newcookie, $expiretime, "/", $controlrow["cookiedomain"], 0);
        die(header("Location: index.php"));
        
    } else {
        
        display("Log In", gettemplate("login"), false);
        
    }
    
}

function logout() {
    
    include("globals.php");
    setcookie($controlrow["cookiename"], "", (time()-3600), "/", $controlrow["cookiedomain"], 0);
    die(header("Location: login.php?do=login"));
    
}

?>
i would like it return to the homepage instead of going to the login.php script. if you need to knw the home page is http://www.vego.clanteam.com thanks so much for your guys time!

Re: login script question

Posted: Sat Jan 16, 2010 8:43 pm
by hallsofvallhalla
looks like here

Code: Select all

function logout() {
   
    include("globals.php");
    setcookie($controlrow["cookiename"], "", (time()-3600), "/", $controlrow["cookiedomain"], 0);
    die(header("Location: login.php?do=login"));

should be

Code: Select all

function logout() {
   
    include("globals.php");
    setcookie($controlrow["cookiename"], "", (time()-3600), "/", $controlrow["cookiedomain"], 0);
    die(header("Location:http://www.vego.clanteam.com"));

Re: login script question

Posted: Sat Jan 16, 2010 8:54 pm
by rapid3642
thanks halls! although i did try that the first time and it didnt work so then i tried it again and still wants to logout to the login.php im not sure why it wants to do that but here is the script with halls's help

login.php

Code: Select all

<?php // login.php :: Handles user logins and logouts.


include("lib.php");
if (isset($_GET["do"])) { $do = $_GET["do"]; } else { $do = ""; }

switch($do) {
    case "logout":
        logout();
        break;
    default:
        login();
}

function login() {
    
    $controlrow = dorow(doquery("SELECT * FROM <<control>> WHERE id='1' LIMIT 1"));
    
    if (isset($_POST["submit"])) {
        
        // Setup.
        include("config.php");
        extract($_POST);
        $query = doquery("SELECT * FROM <<accounts>> WHERE username='$username' LIMIT 1");
        $row = dorow($query);
        
        // Errors.
        if ($row == false) { err("Invalid username. Please <a href=\"index.html\">go back</a> and try again.", false, false); }
        if ($row["password"] != md5($password)) { err("Invalid password. Please <a href=\"index.html\">go back</a> and try again.", false, false); }
        if ($row["verifycode"] != 1) { err("You have not yet verified your account. Please click the link found in your Account Verification email before continuing. If you never received the email, please check your spam filter settings or contact the game administrator for further assistance.", false, false); }
        
        // Finish.
        $newcookie = $row["id"] . " " . $username . " " . md5($row["password"] . "--" . $dbsettings["secretword"]);
        if (isset($remember)) { $expiretime = time()+31536000; $newcookie .= " 1"; } else { $expiretime = 0; $newcookie .= " 0"; }
        setcookie($controlrow["cookiename"], $newcookie, $expiretime, "/", $controlrow["cookiedomain"], 0);
        die(header("Location: index.php"));
        
    } else {
        
        display("Log In", gettemplate("login"), false);
        
    }
    
}

function logout() {
   
    include("globals.php");
    setcookie($controlrow["cookiename"], "", (time()-3600), "/", $controlrow["cookiedomain"], 0);
    die(header("Location:http://www.vego.clanteam.com"));
}

?>

Re: login script question

Posted: Sat Jan 16, 2010 9:05 pm
by rapid3642
o and im sorry but i tried putting instead of the url for the logout i also tried putting the home page file which is index.html

Code: Select all

<?php // login.php :: Handles user logins and logouts.


include("lib.php");
if (isset($_GET["do"])) { $do = $_GET["do"]; } else { $do = ""; }

switch($do) {
    case "logout":
        logout();
        break;
    default:
        login();
}

function login() {
    
    $controlrow = dorow(doquery("SELECT * FROM <<control>> WHERE id='1' LIMIT 1"));
    
    if (isset($_POST["submit"])) {
        
        // Setup.
        include("config.php");
        extract($_POST);
        $query = doquery("SELECT * FROM <<accounts>> WHERE username='$username' LIMIT 1");
        $row = dorow($query);
        
        // Errors.
        if ($row == false) { err("Invalid username. Please <a href=\"index.html\">go back</a> and try again.", false, false); }
        if ($row["password"] != md5($password)) { err("Invalid password. Please <a href=\"index.html\">go back</a> and try again.", false, false); }
        if ($row["verifycode"] != 1) { err("You have not yet verified your account. Please click the link found in your Account Verification email before continuing. If you never received the email, please check your spam filter settings or contact the game administrator for further assistance.", false, false); }
        
        // Finish.
        $newcookie = $row["id"] . " " . $username . " " . md5($row["password"] . "--" . $dbsettings["secretword"]);
        if (isset($remember)) { $expiretime = time()+31536000; $newcookie .= " 1"; } else { $expiretime = 0; $newcookie .= " 0"; }
        setcookie($controlrow["cookiename"], $newcookie, $expiretime, "/", $controlrow["cookiedomain"], 0);
        die(header("Location: index.php"));
        
    } else {
        
        display("Log In", gettemplate("login"), false);
        
    }
    
}

function logout() {
   
    include("globals.php");
    setcookie($controlrow["cookiename"], "", (time()-3600), "/", $controlrow["cookiedomain"], 0);
    die(header("Location:index.html"));
}

?>
and then tried

Code: Select all

<?php // login.php :: Handles user logins and logouts.


include("lib.php");
if (isset($_GET["do"])) { $do = $_GET["do"]; } else { $do = ""; }

switch($do) {
    case "logout":
        logout();
        break;
    default:
        login();
}

function login() {
    
    $controlrow = dorow(doquery("SELECT * FROM <<control>> WHERE id='1' LIMIT 1"));
    
    if (isset($_POST["submit"])) {
        
        // Setup.
        include("config.php");
        extract($_POST);
        $query = doquery("SELECT * FROM <<accounts>> WHERE username='$username' LIMIT 1");
        $row = dorow($query);
        
        // Errors.
        if ($row == false) { err("Invalid username. Please <a href=\"index.html\">go back</a> and try again.", false, false); }
        if ($row["password"] != md5($password)) { err("Invalid password. Please <a href=\"index.html\">go back</a> and try again.", false, false); }
        if ($row["verifycode"] != 1) { err("You have not yet verified your account. Please click the link found in your Account Verification email before continuing. If you never received the email, please check your spam filter settings or contact the game administrator for further assistance.", false, false); }
        
        // Finish.
        $newcookie = $row["id"] . " " . $username . " " . md5($row["password"] . "--" . $dbsettings["secretword"]);
        if (isset($remember)) { $expiretime = time()+31536000; $newcookie .= " 1"; } else { $expiretime = 0; $newcookie .= " 0"; }
        setcookie($controlrow["cookiename"], $newcookie, $expiretime, "/", $controlrow["cookiedomain"], 0);
        die(header("Location: index.php"));
        
    } else {
        
        display("Log In", gettemplate("login"), false);
        
    }
    
}

function logout() {
   
    include("globals.php");
    setcookie($controlrow["cookiename"], "", (time()-3600), "/", $controlrow["cookiedomain"], 0);
    die(header("Location:http://www.vego.clanteam.com/index.html"));
}

?>

for some reason nothing works is there an alternative to make it return after dieing?

Re: login script question

Posted: Sat Jan 16, 2010 10:19 pm
by hallsofvallhalla
does your index had a login redirect?

Re: login script question

Posted: Sun Jan 17, 2010 4:27 am
by rapid3642
yup thats wat is was, but it was reffering to a different script. Problem solved thanks everyone for contributing to the cause! im sorry for any confusion i made on others. Thanks for your guys time! should i delete this post? or should i leave it for a lesson? that may help others

Re: login script question

Posted: Sun Jan 17, 2010 5:21 am
by hallsofvallhalla
never deleted the posts, people can use this in case they have a similar problem.

glad you got it solved.