Jump to content
php.lv forumi

Problēma ar paroles atkodēšanu no db


djmartins

Recommended Posts

Problēma ir tāda, ka netiek atkodēta parole no datubāzes, kas šeit varētu būt nepareizi, jeb arī problēma meklējama pašā datubāzē?

 

<?
session_start();
include("config.php"); 

$username=$_POST["username"];
$password=md5($_POST["password"]);

$ress=mysql_query("select * from user where username='$username'") or die(mysql_error());
$rows=mysql_fetch_array($ress);

	if(($rows["username"]==$username)&&($rows["password"]==$password))
	{ 
	  $_SESSION['webuser']=$username; 
	  header ("Location: index.php");
	}

	else { header ("Location: index1.php"); }

?>

Link to comment
Share on other sites

Nu pirmām kārtām, dīdžei mārtiņ, paskaties kas ir mysql_real_escape_string.

 

Tālāk - no md5 atpakaļ oriģinālo paroli tu nedabūsi un tas nav vajadzīgs. Lai pārbaudītu vai ievadītā parole ir īstā salīdzini paroles hašu.

 

$pass = "parole" //ievadītā parole
$pass_from_db = "xxx...." //paroles hash
if(md5($pass) == $pass_from_db) {
echo "Viss OK"
}

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...