Apache 2.0
PHP 4.4
MySQL 5.0
=========
Ok, here what is going on! Every time when I trying to login into system I’m getting message (its last “else” in F_LogIn function):
“Nothing is working”
and so result of this:
“You could not be logged in”
I don’t know why it’s happen, but by testing my query, I found out that problem in “user_password” , without this parameter everything is working smoothly. To be more precise, the query is not returning any row from DB.
Because of this I’m seriously stuck and can’t move on with this project. I didn’t found any tips in internet so decided to post here.
[php]<?php
$user_name = $_POST ["user_name"];
$user_password = $_POST ["user_passw ord"];
session_start ();
if ($user_name && $user_password)
{
if (F_LogIn ($user_name, $user_password) )
{
$valid_user = $user_name;
$_SESSION ['valid_user'] = $user_name;
}
else
{
print "You could not be logged in <br />";
print "NAME = $user_name <br /> PASSWORD = $user_password <br />";
exit;
}
}
F_CheckValidUse r ();
?>
<br />
<a href = "LogOut.php">Lo gOut</a>
<?php
function F_LogIn ($user_name, $user_password)
{
$connection_sta tus = F_DBConnect();
if (!$connection_s tatus)
{
print "No connection to DB";
return false;
}
$query = "SELECT * FROM tbl_user_detail WHERE clm_user_name = '$user_name' AND clm_password = OLD_PASSWORD ('$user_passwor d')";
$query_result = mysql_query ($query, $connection_sta tus);
//$query_result_2 = mysql_fetch_row ($query_result) ;
//print $query_result_2 ["clm_user_n ame"];
if (!$query_result )
{
print "Invalide query";
return false;
}
else
{
if (mysql_num_rows ($query_result) )
{
print "Query OK" . mysql_num_rows ($query_result) . "<br />";
return true;
}
else
{
print "<br />Nothing is working " . mysql_num_rows ($query_result) . "<br />";
return false;
}
}
}
function F_DBConnect ()
{
$connection_sta tus = mysql_pconnect ("localhost" , "root", "111");
if (!$connection_s tatus)
{
return false;
}
if (!mysql_select_ db ("test", $connection_sta tus))
{
return false;
}
return $connection_sta tus;
}
function F_CheckValidUse r ()
{
//global $valid_user;
if (isset($_SESSIO N ['valid_user']))
{
print "Logged in as " . $valid_user . "<br />";
?>
<br />
<a href = "LogOutTest.php "> Log Out Test</a>
<br />
<?php
}
else
{
print "You are not logged in <br />";
?>
<a href = "LogInForm.php" >Log In</a>
<br />
<a href = "LogOut.php">Lo g Out</a>
<br />
<a href = "LogOutTest.php "> Log Out Test</a>
<?php
exit;
}
}
?>[/php]
And one more thing, the query that used to register user is:
[php]...
$query_result = mysql_query ("INSERT INTO tbl_user_detail
VALUES ('$user_name', OLD_PASSWORD('$ user_password') , '$user_email')" );...[/php]
PHP 4.4
MySQL 5.0
=========
Ok, here what is going on! Every time when I trying to login into system I’m getting message (its last “else” in F_LogIn function):
“Nothing is working”
and so result of this:
“You could not be logged in”
I don’t know why it’s happen, but by testing my query, I found out that problem in “user_password” , without this parameter everything is working smoothly. To be more precise, the query is not returning any row from DB.
Because of this I’m seriously stuck and can’t move on with this project. I didn’t found any tips in internet so decided to post here.
[php]<?php
$user_name = $_POST ["user_name"];
$user_password = $_POST ["user_passw ord"];
session_start ();
if ($user_name && $user_password)
{
if (F_LogIn ($user_name, $user_password) )
{
$valid_user = $user_name;
$_SESSION ['valid_user'] = $user_name;
}
else
{
print "You could not be logged in <br />";
print "NAME = $user_name <br /> PASSWORD = $user_password <br />";
exit;
}
}
F_CheckValidUse r ();
?>
<br />
<a href = "LogOut.php">Lo gOut</a>
<?php
function F_LogIn ($user_name, $user_password)
{
$connection_sta tus = F_DBConnect();
if (!$connection_s tatus)
{
print "No connection to DB";
return false;
}
$query = "SELECT * FROM tbl_user_detail WHERE clm_user_name = '$user_name' AND clm_password = OLD_PASSWORD ('$user_passwor d')";
$query_result = mysql_query ($query, $connection_sta tus);
//$query_result_2 = mysql_fetch_row ($query_result) ;
//print $query_result_2 ["clm_user_n ame"];
if (!$query_result )
{
print "Invalide query";
return false;
}
else
{
if (mysql_num_rows ($query_result) )
{
print "Query OK" . mysql_num_rows ($query_result) . "<br />";
return true;
}
else
{
print "<br />Nothing is working " . mysql_num_rows ($query_result) . "<br />";
return false;
}
}
}
function F_DBConnect ()
{
$connection_sta tus = mysql_pconnect ("localhost" , "root", "111");
if (!$connection_s tatus)
{
return false;
}
if (!mysql_select_ db ("test", $connection_sta tus))
{
return false;
}
return $connection_sta tus;
}
function F_CheckValidUse r ()
{
//global $valid_user;
if (isset($_SESSIO N ['valid_user']))
{
print "Logged in as " . $valid_user . "<br />";
?>
<br />
<a href = "LogOutTest.php "> Log Out Test</a>
<br />
<?php
}
else
{
print "You are not logged in <br />";
?>
<a href = "LogInForm.php" >Log In</a>
<br />
<a href = "LogOut.php">Lo g Out</a>
<br />
<a href = "LogOutTest.php "> Log Out Test</a>
<?php
exit;
}
}
?>[/php]
And one more thing, the query that used to register user is:
[php]...
$query_result = mysql_query ("INSERT INTO tbl_user_detail
VALUES ('$user_name', OLD_PASSWORD('$ user_password') , '$user_email')" );...[/php]