Jump to content

Need Help With My Login Script


coldfirezz

Recommended Posts

I cant figure out what is wrong with my login script....

You can try it out on my website here: http://sereneadventure.net/area51/login.php (Usernmame:Test and Pass: Test)

The Errors Are As Follows:

FF: Source

IE: No Working

Chrome: Page Not Avalible

Heres the code:

<?php

session_start();

$Direct=".";

$Design="design";

include("".$Direct."/inc/database.php");

include("".$Direct."/inc/global.php");

 

//Already Logged In

if(isset($_COOKIE['Username']))

{

include("".$Direct."/inc/head.php");

include("".$Direct."/inc/start.php");

include("".$Direct."/".$Design."/banner.php");

$Caption="Error";

include("".$Direct."/".$Design."/caption.php");

include("".$Direct."/".$Design."/tablep1.php");

echo"You are already logged in";

include("".$Direct."/".$Design."/tablep2.php");

die;

}

//End Already Logged In

 

elseif($_GET['action']==start){

$Username = $_POST["username"];

$Pass = $_POST["password"];

$Password = md5($Pass);

 

$db = mysql_select_db('Members');

 

//Check Username entered

$Check = "SELECT Username FROM Users WHERE Username = '".$Username."'";

$CheckDB = mysql_query($Check,$con);

$Amount = mysql_num_rows($CheckDB);

 

//Username Does not exist

if($Amount == 0)

{

include("".$Direct."/inc/head.php");

include("".$Direct."/inc/start.php");

include("".$Direct."/".$Design."/banner.php");

$Caption="Error";

include("".$Direct."/".$Design."/caption.php");

include("".$Direct."/".$Design."/tablep1.php");

echo"The Username You Entered Does not Exist";

include("".$Direct."/".$Design."/tablep2.php");

die;

}

//End Username Does Not Exist

 

//Check to see if password for user is correct

$Check = "SELECT Password FROM Users WHERE Username='$Username'";

$CheckDB = mysql_query($Check,$con);

$row = mysql_fetch_array($CheckDB);

 

//Password is inncorrect

if($row['Password'] != $Password)

{

include("".$Direct."/inc/head.php");

include("".$Direct."/inc/start.php");

include("".$Direct."/".$Design."/banner.php");

$Caption="Error";

include("".$Direct."/".$Design."/caption.php");

include("".$Direct."/".$Design."/tablep1.php");

echo"Password does not match. Please Try Again.";

include("".$Direct."/".$Design."/tablep2.php");

die;

}

//Log user in

else{

setcookie("Username","".$Username."",$CookieTime,"/");

setcookie("Password","".$Password."",$CookieTime,"/");

setcookie("SessionEnd", "True",$CookieTime,"/");

 

$result = mysql_query("SELECT * FROM Users WHERE Username = '".$Username."'");

while($row = mysql_fetch_array($result)){

setcookie("UserID", "".$row['ID']."",$CookieTime,"/");

$UserID=$row['ID'];

setcookie("Access_Level", "".$row['Access_Level']."",$CookieTime,"/");

}

 

$db = mysql_select_db('Promo');

$result = mysql_query("SELECT * FROM Battle WHERE Name='Coins'");

while($row = mysql_fetch_array($result)){

setcookie("ExpPromo","".$row['Times']."",$CookieTime,"/");

}

if($_COOKIE['CoinPromo']==0){

setcookie("CoinPromo","1",$CookieTime,"/");

}

setcookie("ExpPromo","1");

$result = mysql_query("SELECT * FROM Battle WHERE Name='Exp'");

while($row = mysql_fetch_array($result)){

setcookie("ExpPromo","1",$row['Times'],"/");

}

if($_COOKIE['ExpPromo']==0){

setcookie("ExpPromo","1",$CookieTime,"/");

}

 

include("".$Direct."/inc/selectcharacterlogin.php");

include("".$Direct."/inc/selectnpc.php");

 

include("".$Direct."/inc/head.php");

include("".$Direct."/inc/start.php");

include("".$Direct."/design/banner.php");

$Caption="Success!";

include("".$Direct."/".$Design."/caption.php");

include("".$Direct."/".$Design."/tablep1.php");

echo"Your Login was successful. Please wait while you are redirected.";

include("".$Direct."/".$Design."/tablep2.php");

 

$db = mysql_select_db('Members');

$Edit="UPDATE Users SET UniqueID='".$SessionID."', Location='".$Location."' WHERE Username='".$Username."'";

mysql_query($Edit, $con);

 

$db = mysql_select_db('Logs');

$sql = "INSERT INTO Login (Action, IP, Username, Session,Time)

VALUES ('Logged In', '".$IP."', '".$_COOKIE["Username"]."','".$SessionID."','".$Time."')";

mysql_query($sql,$con);

 

?><meta http-equiv="Refresh" content="4; url=http://sereneadventure.net/area51/"><?php

die;

}

}

else

{

include("".$Direct."/inc/head.php");

include("".$Direct."/".$Design."/banner.php");

$Caption="Login";

include("".$Direct."/".$Design."/caption.php");

include("".$Direct."/".$Design."/tablep1.php");

echo"<form id='login' name='login' method='post' action='login.php?action=start'>

Username<br />

<input type='text' name='username' id='username' /><br />

Password<br />

<input type='password' name='password' id='password' /><br />

<input type='submit' name='login' id='login' value='Login' />

</form>";

include("".$Direct."/".$Design."/tablep2.php");

}

?>

Link to comment
https://forums.phpfreaks.com/topic/132368-need-help-with-my-login-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.