04-10-2007, 15:14
|
|
|
חבר מתאריך: 21.01.06
הודעות: 813
|
|
עשיית התחברות - בעיית אבטחה
עד עכשיו לא שמתי לב שהאתר מאוד פריץ..
בהתחברות שעשיתי עשיתי ככה:
קוד PHP:
<? if (isset ($_POST['remmber'])) $timec = "100000"; else $timec = "3600"; setcookie('users', $_POST['username'] ,time() +$timec); ?> <html dir=rtl> <style> <!-- A:hover { color:#000000;text-decoration; bold;} --> </style> <style type="text/css"> input { font-family: arial, tahoma; font-size: 9pt; color: black; font-weight: bold; } </style> <style type="text/css"> a { text-decoration: none; font-family: arial, tahoma; font-size: 9pt; font-weight: bold; } </style> <meta http-equiv="Content-Type" content="text/html; charset=windows-1255"> <body link="#000000" vlink="#000000" alink="#000000" bgproperties=fixed> <center> <br><br><br> <br><br> <? require ("config.php"); $blaa = mysql_query ("SELECT * From colors"); $bla = mysql_fetch_array ($blaa); ?> <table width="250" height="140" border="1" bgcolor="#00000"> <p dir="center"> <tr><td height="35"><p align="center"><b><font face="Arial" size="2" color="White">שלום אורח, אנא התחבר.<br></font></p></b> </tr></td><tr><td bgcolor="<? echo $bla['color']; ?>"> <form method="POST"><font face="arial" size="1"><br></font> <center><font face="Arial" size="2"><b>שם משתמש:</font></b> <input type="text" size="12" name="username" onfocus="this.value=''" value="שם משתמש"><Br></center> <center><font face="Arial" size="2"><b>סיסמא:</font></b> <input type='password' size='12' name='userpass' onfocus="this.value=''" value='password'></center> <center><input type='submit' name='submit' value='התחבר'> <input type='checkbox' name="remmber"><font face='arial' size='2'> זכור אותי </center> <center><a href="register.php">הרשם עכשיו!</a></center> <?php echo "<font face=Arial size=2>"; $user = $_POST['username']; $pass = $_POST['userpass']; $query = mysql_query ("SELECT * FROM uses WHERE `user_name`='$user' AND `user_pass`='$pass' "); $num = mysql_num_rows ($query); if ( isset ($_POST ['submit'] )) { if ($num <= 0) echo "<br>השם משתמש או הסיסמא אינם נכונים"; elseif ($num > 0) { echo "<br>אנא המתן.."; ?> <meta http-equiv="refresh" content="1;url=cp.php"> <?php echo "</table></tr></td>"; } } echo "</font>"; ?> </p> </center> </html>
(אני יודע שזה לא מסודר, פעם עבדתי ככה היום פחות)
הבעיה שאי אפשר היה לשים לב אליה,
שמספיק שכותבים את שם המשתמש ושולחים(גם אם הסיסמא לא נכונה), העוגיות נשמרות ואז
אפשר פשוט להיכנס ידנית לאתר דרך הלינק שלו..
איך אני יכול לעשות, שהעוגייה תשלח רק אם השם משתמש והסיסמא נכונים
(זה אמור להיות במקטע שכתוב "אנא המתן..")
ניסיתי כמה דרכים ולא הסתדרתי..
אני לא יכול לשים את העוגייה באמצע הדף כי הדפסתי תוכן לפני זה, אבל אני גם לא יכול להשתמש
במשתנים שאני יקבל רק אחרי שליחת הטופס, אם העוגייה נמצאת למעלה..
בקיצור יש למישהו הצעה איך לעשות את זה? תודה לעוזרים!
_____________________________________
--- ! Area Close ! ---
|