Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.