הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   מס' שאלות . (https://hosts.co.il/forums/showthread.php?t=18227)

bestdesign 22-03-06 16:24

מס' שאלות .
 
אני רוצה ליצור לוגין , והסיסמאות מוצפנות ב-md5 כיצד אני יכול לבדוק האם מה שהזינו תואם כיוון שאי אפשר להשוות משתנה עם md5 .... ?

2.מה זה סשן ? ומתי אצטרך אותו ?

miniature 22-03-06 16:33

בדיקת הצפנה (שיש ב DB):
PHP קוד:

function CalculatePassword($pass)
{
    
$pass=$pass[0].$pass.$pass[0];
   
$pass=md5($pass);
   return 
$pass;
}

function 
CheckUserPassword($user,$pass,$with_calc=true)
{
    global 
$protect_user_group;

    if (
$user=="" || $pass=="")
       return 
false;

  
$sql=@mysql_connect("localhost","user_db","pass") or die("<BR>ERROR: cannot connect to MySQL server!");
  @
mysql_select_db("user_db",$sql) or die("<BR>ERROR: cannot use the DB!");

   
$c_pass=($with_calc==true)?CalculatePassword($pass):$pass;
   
$res=@mysql_query("SELECT user FROM table WHERE (user='".$user."' AND pass='".$c_pass."')",$sql) or die("<br />ERROR: incorrect query!");

   if (
mysql_num_rows($res)==1)
       return 
$c_pass;
   return 
false;

   @
mysql_close($sql);


בקשר לסשן - זה בעצם 'משאיר אותך מחובר' ללוח הבקרה או לאיזה עמוד שתשים בו סשן.

תהנה :)


כל הזמנים הם GMT +2. הזמן כעת הוא 08:05.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ