Login Problems

Started on the old forum in July 2007 · view the original in the archive · old links redirect here

4 replies · 568 views · started 19 years ago · 1 min read

2 participants
FlareX #1
<?php //Login To Database include("Database.php"); include("OpenDatabase.php"); //Get The Functions include("Functions.php"); //The Headers header("Content-type: text/html; charset=ISO-8859-1"); echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";

echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; ?>

<?php $username=$_GET['username']; $password=$_GET['password']; ////////////////////////////////////////LOGIN!!! //Page Title And CSS Theme echo FlareXhead($uthm,$stitle); echo " "; echo "".date("D d M y - H:i",time() )."</a> "; $TimeZone="0"; ////Change the TimeZone accordingly! $New_Time = time() + ($TimeZone * 60 * 60); $show_date=date("D dS F, Y",$New_Time); $show_time=date("H:i",$New_Time); $Hour=date("G",$New_Time); echo " "; echo " "; //Check Password Query $check_pass="SELECT Password FROM members WHERE Password='$password'"; $check_password=mysql_fetch_array(mysql_query($check_pass)); //Check User Query $check_user="SELECT Username FROM members WHERE Username='$username'"; $Check_Username=mysql_fetch_array(mysql_query($check_user)); //Sucsessful Login if ($username==$check_username) { if ($password==$check_password) { echo "==========</a> "; echo "Username: **$username**</a> "; echo "----------</a> "; echo "Password: **$password**</a> "; echo "==========</a> "; echo "<a href=\"index.php?action=main&username=$username&password=$password\">Login Now!</a>"; } }else{ //Incorrect Login echo "Your Login Details Are Incorrect"; echo " "; //End Page echo FlareXfoot(); } ?>

Its Not Checking If The Login Details Are Correct , Its Just Going To The Else Function And Saying That The Details Is Wrong , Ne1 No Why?

nclemale36 Lead · 537 posts #2
<?php //Login To Database include("Database.php"); include("OpenDatabase.php"); //Get The Functions include("Functions.php"); //The Headers header("Content-type: text/html; charset=ISO-8859-1"); echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";

echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; ?>

<?php $username=$_GET['username']; $password=$_GET['password']; ////////////////////////////////////////LOGIN!!! //Page Title And CSS Theme echo FlareXhead($uthm,$stitle); echo " "; echo "".date("D d M y - H:i",time() )."</a> "; $TimeZone="0"; ////Change the TimeZone accordingly! $New_Time = time() + ($TimeZone * 60 * 60); $show_date=date("D dS F, Y",$New_Time); $show_time=date("H:i",$New_Time); $Hour=date("G",$New_Time); echo " "; echo " "; //Check Password Query $check_pass="SELECT Password FROM members WHERE Password='$password'"; $check_password=mysql_fetch_array(mysql_query($check_pass)); //Check User Query $check_user="SELECT Username FROM members WHERE Username='$username'"; $Check_Username=mysql_fetch_array(mysql_query($check_user)); //Sucsessful Login if ($username==$check_username) { if ($password==$check_password) { echo "==========</a> "; echo "Username: **$username**</a> "; echo "----------</a> "; echo "Password: **$password**</a> "; echo "==========</a> "; echo "<a href=\"index.php?action=main&username=$username&password=$password\">Login Now!</a>"; } }else{ //Incorrect Login echo "Your Login Details Are Incorrect"; echo " "; //End Page echo FlareXfoot(); } ?>

Its Not Checking If The Login Details Are Correct , Its Just Going To The Else Function And Saying That The Details Is Wrong , Ne1 No Why?

are your include files correct. ie the database name and passwords etc.

Guest #3

the most likely problem is the name of the database table being incorrect .. by the sounds of it, you are able to connect to the database okay, thus indicating that your name+password are correct, but if the name of the database table is correct it would show this kind of error

woah .. err .. that code is really dodgy :/ try this code but edit a few of the links

you need to fix your sql codes, i also noticed on the script above it said $Check_Username which is different to $check_username i also question why your code displays the login boxes if the username and pass DO match??

the script below counts how many rows in the database have Username = $username if the username cant be found, displays an error message saying the username is incorrect if the username is found, check if there is an entry with that username AND password combination elseif the username and password combination cannot be found, display an error message saying the password is incorrect (the username must exist if they have gotten this far) elseif the username + password are correct, show the login successful page

<?php
//Login To Database
include("Database.php");
include("OpenDatabase.php");

//Get The Functions
include("Functions.php");

//The Headers
header("Content-type: text/html; charset=ISO-8859-1");

echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";

$username=$_GET['username'];
$password=$_GET['password'];

////////////////////////////////////////LOGIN!!!

//Page Title And CSS Theme
echo FlareXhead($uthm,$stitle);

/*
echo "<p align=\"center\">";
$TimeZone="0"; ////Change the TimeZone accordingly!
$New_Time = time() + ($TimeZone * 60 * 60);

$show_date=date("D dS F, Y",$New_Time); 
$show_time=date("H:i",$New_Time); 
$Hour=date("G",$New_Time);

echo "[size="1"]".date("D d M y)." - $show_time </a>[/size]
";
echo "</p>";
*/

echo "

";

// check if the username and password have been filled in, if they havent, then show the login box
if (($username == "") && ($password == "")){

echo "==========</a>
";
echo "Username: [b]$username[/b]</a>
";
echo "----------</a>
";
echo "Password: [b]$password[/b]</a>
";
echo "==========</a>
";
echo "<a href=\"**LOGIN URL**.php?action=**LOGIN**&username=$username&password=$password\">Login Now!</a>";

}else{

//check the username by counting how many matching rows exist 
$check_username = mysql_query("SELECT COUNT(*) FROM members WHERE Username='".$username."'");
$check_password = mysql_query("SELECT COUNT(*) FROM members WHERE Username='".$username."' AND Password='".$password."' ");

// if username does not exist or is blank, then show error output
  if ((!$check_username > 0) || ($username == "")){
echo "username cannot be found or you have entered a blank input
";
  }
// elseif check whether the username/password combination exist in the database or the password input is blank
  if ((!$check_password == "1") || ($password == "")){
echo "password is incorrect or you have entered a blank input
";
  }
// elseif double check that the combo does exist .. if the username and pass are in the database, show the successful login page
 elseif($check_password == "1"){
echo "LOGIN PAGE 
LOGIN PAGE 
";
echo "you have successfully been logged in
";
echo "<a href=\"**LINK URL**\">LOGIN</a>
";
echo "LOGIN PAGE 
LOGIN PAGE 
";
  }
// if for some odd reason none of those fit -- should never occur
else {
echo "there was an error somewhere - please report this to the site owner including any details about what you may have done to cause this error";
  }

}
echo "</p>";
echo "</card>";
?>
</wml>
FlareX #4

Close This Topic , I Fixed The Problem

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close