Menu
hi, i problem for my php codes. i already stored username and password in mysql db. now im using login page to enter username and password to check im entering correct or not. but i don`t know the coding. plz anybody send codes.byee..
[code=php]"SELECT * FROM newuser WHERE USER_NAME='".mysql_real_escape_string($_POST['user'])."'";[/code]
[code=php]$con = mysql_connect("mysql4.000webhost.com", "**I have hidden this**", "**I have hidden this**");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// Define username and password variables for returned post method
$username = $_POST["username"];
$password = $_POST["password"];
if($username != "" || $password != "")
{
$query = mysql_query("SELECT username FROM members WHERE username = '" . $username . "' AND password = PASSWORD('" . $password . "')", $con);
// Select database and log on
mysql_select_db("a4413978_db", $con);
$num = mysql_num_rows($query);
echo $num;
if($num != 0)
{
$result = mysql_result($query, 0);
echo $result;
}
$row=mysql_fetch_array($result)
//{
//$user=$row['username'];
//$pass=$row['password'];
//}
//if($username == $user && $password ==$pass)
//{
//header("Location: index.php");
//}
//else if($password!= $pass ||$username != $user )
//{
//echo("Please Enter Correct Username and Password ...");
//header("Location: test.php");
//}
[/code]
[code=php]
$query = mysql_query("SELECT username FROM members WHERE username = '" . $username . "' AND password = PASSWORD('" . $password . "')", $con);
// Select database and log on
mysql_select_db("a4413978_db", $con);
[/code]
[code=php]
// Select database and log on
mysql_select_db("a4413978_db", $con);
$query = mysql_query("SELECT username FROM members WHERE username = '" . $username . "' AND password = PASSWORD('" . $password . "')", $con);
if(mysql_errno()) {
die('query error: '.mysql_error());
}
[/code]
header("location: userpage.php");
simply post ur user name and password to checklogin.php page
then
on checklogin.php page write this
$c=mysql_connect("server","username","password");
mysql_select_db("databasename",$c);
extract($_REQUEST);
$result=mysql_query("select * from table where userfeild='$user' and passwordfeild='$password'");
if(mysql_num_rows($result))
{
header("location: userpage.php");
}
else
{
header("location: invalidpage.php");
}[/QUOTE]
FYI: The MySQL documentation explicitly says NOT to use the PASSWORD function for storing application passwords!!! It is not necessarily compatible with any other password hash algorithms and is subject to change at any time! Crypt your passwords with a standard like SHA![/QUOTE]
hi, i problem for my php codes. i already stored username and password in mysql db. now im using login page to enter username and password to check im entering correct or not. but i don`t know the coding. plz anybody send codes.byee..[/QUOTE]
0.1.9 — BETA 5.6