php කාපර්ලා - Help Needed

PHP දන්නා අය පොඩ්ඩක් මේකේ වැරැද්ද පෙන්නලා දෙන්න .
මචන්ලා මම දවසක් විතර තිස්සේ මේ code එකේ වැරැද්ද හොයනවා . ඒත් හොයාගන්න බැහැ:( . Lynda-PHP එකෙන් බලලා තමයි ඉගෙනගත්තේ . Tutorial එක කරන එක්කෙනාගෙයි මගෙයි codes අතර වෙනසක් නැහැ . ඒත් මගේ එකේ අව්ලක් තියෙනවා .

මේකයි scenario එක . මම users ලව db එකට කරනවා . ඊට පස්සේ ඒගොල්ලෝ log වෙද්දී බලනවා username & password හරිද කියලා . DB එකේ ඉන්න user ලට විතරයි log වෙන්න දෙන්නේ . අනිත් අයට username/password does not match කියලerror එකක් දෙනවා . මේක login authentication system එකක්. අවුල කියන්නේ DB එකේ ඉන්න userla ලත් log වෙද්දී username/password does not match කියල error එක දෙනවා නේ .

මේකේ php කාපර්ලා ඉන්නවා නේ . පොඩ්ඩක් වෙලා code එක දිහා බලලා උදව්වක් දියන් . පින් සිද්ද වෙයි .:)


එළකිරි එකේ codes ලස්සනට දාන්න මට තේරෙන්නේ නැහැ බන්:rolleyes:

Link to code
http://www.mediafire.com/view/0yxmwzw575ox09e/code.php

connect_database.php කියන file එක දැම්මේ නැහැ . එකේ නම් වැරද්දක් නැහැ කියලා sure

දන්නත්තම් බම්ප් හරි කරපල්ලා මචන්ලා
 
Last edited:

Arkham Knight

Member
Mar 14, 2014
1,627
89
0
Error එකක්ද එන්නේ නැත්නම්
'Username/pasword does not match'; කියන message එක විතරමද පෙන්වන්නේ?

ඕකට හොදම වැඩේ exception handling දාලා බලන්න ඊට පස්සේ එන message එක බලන්න.

Code:
[FONT=Verdana][SIZE=3]try
  {
[/SIZE][/FONT][FONT=Verdana][SIZE=3]            $username=  cleanData($_POST['username']);             $password= passwordEncrypt($_POST['password']);               $found_user=  loginAttempt($username, $password);             if($found_user){                echo 'Welcome '.$found_user['username'];             }else{                 echo 'Username/pasword does not match';             }[/SIZE][/FONT][FONT=Verdana][SIZE=3]   }

catch(Exception $error)
  {
  echo 'Message: ' .$error->getMessage();
  }
[/SIZE][/FONT]
 
issellama login weddi encrypt wena password eka print karala balanna database eke password ekata match wenawada kiyala
machan e deka wenas bun
Error එකක්ද එන්නේ නැත්නම්
'Username/pasword does not match'; කියන message එක විතරමද පෙන්වන්නේ?

ඕකට හොදම වැඩේ exception handling දාලා බලන්න ඊට පස්සේ එන message එක බලන්න.

Code:
[FONT=Verdana][SIZE=3]try
  {
[/SIZE][/FONT][FONT=Verdana][SIZE=3]            $username=  cleanData($_POST['username']);             $password= passwordEncrypt($_POST['password']);               $found_user=  loginAttempt($username, $password);             if($found_user){                echo 'Welcome '.$found_user['username'];             }else{                 echo 'Username/pasword does not match';             }[/SIZE][/FONT][FONT=Verdana][SIZE=3]   }

catch(Exception $error)
  {
  echo 'Message: ' .$error->getMessage();
  }
[/SIZE][/FONT]
Error ekak enne naha.'Username/pasword does not match'; kiyala watenne. mama try ekak dennam
thanks
 
Error එකක්ද එන්නේ නැත්නම්
'Username/pasword does not match'; කියන message එක විතරමද පෙන්වන්නේ?

ඕකට හොදම වැඩේ exception handling දාලා බලන්න ඊට පස්සේ එන message එක බලන්න.

Code:
[FONT=Verdana][SIZE=3]try
  {
[/SIZE][/FONT][FONT=Verdana][SIZE=3]            $username=  cleanData($_POST['username']);             $password= passwordEncrypt($_POST['password']);               $found_user=  loginAttempt($username, $password);             if($found_user){                echo 'Welcome '.$found_user['username'];             }else{                 echo 'Username/pasword does not match';             }[/SIZE][/FONT][FONT=Verdana][SIZE=3]   }

catch(Exception $error)
  {
  echo 'Message: ' .$error->getMessage();
  }
[/SIZE][/FONT]
machan exception ekak pannine naha bun. Username/password does not match kiyala thamai watenne
 

Arkham Knight

Member
Mar 14, 2014
1,627
89
0
විල්සන් මාමා;16396634 said:
machan exception ekak pannine naha bun. Username/password does not match kiyala thamai watenne

මම කලින් reply එක දැක්කා ඒකට අනුව password hash වීමේදි ප්‍රශ්ණයක් තියෙන්නේ කලින් කියලා තියෙනවා වගේ. password එක hash කරන්න sha1() function එක use කරන්න ඔච්චර code එකක් ඕනේ නෑ.
Code:
function passwordEncrypt($password) {     $hashFormat="$2y$10$"; // Tells PHP to use blowfish with a cost of 10     $saltLength=22 ;//Blowfish salts should be 22 characters or more     $salt=generateSalt($saltLength); // generate a salt using a function     $formatAndSalt=$hashFormat.$salt;     $hashPassword=crypt($password,$formatAndSalt);     return $hashPassword; }
 

වෙනුවට

function passwordEncrypt($password) {     return sha1($password); }
 
use කරන්න.
 
මම කලින් reply එක දැක්කා ඒකට අනුව password hash වීමේදි ප්‍රශ්ණයක් තියෙන්නේ කලින් කියලා තියෙනවා වගේ. password එක hash කරන්න sha1() function එක use කරන්න ඔච්චර code එකක් ඕනේ නෑ.
Code:
function passwordEncrypt($password) {     $hashFormat="$2y$10$"; // Tells PHP to use blowfish with a cost of 10     $saltLength=22 ;//Blowfish salts should be 22 characters or more     $salt=generateSalt($saltLength); // generate a salt using a function     $formatAndSalt=$hashFormat.$salt;     $hashPassword=crypt($password,$formatAndSalt);     return $hashPassword; }
 

වෙනුවට

function passwordEncrypt($password) {     return sha1($password); }
 
use කරන්න.
hmmm machan sha1 use karanna epa kiyala kiyanawa ne. Eka hidama thamai mama blowfish use kale. ubala samanyen industry ekedi sha1 use karanawada?
 
ahhh ethana thamai awla ... othana hemathissema password ekak generate wenne unique random id ekak aragena

login weddith aluth password ekak hadenne ... function eka wenas karanna wenawa
matath oka hithuna. Salt eka random widiyata generate karanne nathuwa. fixed ekak thiyagaththanam hari yai. mama poddak try ekak deela ena result eka dannam. Thanks machanla