Jump to content

login script with md5 password


luvlemonade

Recommended Posts

i have never used md5 password for user register before. i juz made it and  it worked, but im having problem in login script

here is the code:

<?php
session_start();
# get value that was sent from the form
$username = $_POST['username'];
$pwd = md5($_POST['password']);

# username and password may not be empty
if (empty($username) or empty($pwd))
{
echo "username  or password may not be empty";
die ("<a href='login.php'>Login Ulang</a>");
}

# login prosses
$valid = check_user($username,$pwd);
if ($valid == true)
{
check_valid_user($username,$pwd);
header("location:index.php");
}
else
{
header("location:errLogin.php");
}
#################### Definition of function #########################
function check_user($username, $pwd)
{ 

include('connect/configdb.php');
$sql="select count(*) from member
  where username = '$username' and password = '$pwd'";
$result = mysql_query($sql);
$rows=mysql_fetch_row($hasil);
if ($rows[0] > 0)
  return true;

else

  return false;
}
function cek_valid_user($username,$pwd)
{
include('connect/configdb.php');
  $sql="select * from member 
  		where username='$username' and password='$pwd'";
$result=mysql_query($sql);
$rec=mysql_fetch_assoc($result);

$_SESSION['username']=$rec['username'];
$_SESSION['logged_in']=TRUE;
header("location:index.php");
}
?>


 

duhhh can anyone please show where the error is

Link to comment
https://forums.phpfreaks.com/topic/50906-login-script-with-md5-password/
Share on other sites

A little more description would be helpful. What error message are you getting? What is the script doing? What are you expecting it to do?

 

function cek_valid_user($username,$pwd)

 

check_valid_user($username,$pwd);

 

See the problem?

 

If this don't solve it, then go with what I started off with and give more details.

 

Nate

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.