kristapuciits Posted February 2, 2010 Report Share Posted February 2, 2010 (edited) Rekur pirmā lapa- <html> <body> <form action="login.php" method="post"> Lietotājvārds: <input type="text" name="nick" /> Parole: <input type="text" name="pass" /> <input type="submit" value="Ieiet!" /> </form> </body> </html> šeit otrā lapa login.php - <html> <body> <?php $con = mysql_connect("***","***","***"); //visdrīzāk problēma ir no šīs mysql_select_db("a4285411_db", $con); // rindas //līdz $newnick = mysql_query('SELECT nick FROM users WHERE nick = $_POST["nick"] '); // šitai. if (!$newnick) { mysql_close($con); echo "Ieeja neizdevās! Mēģini vēlreiz!"; } else { $newpass = mysql_query('SELECT pass FROM users WHERE nick = $_POST["nick"] '); if ($newnick == $newpass) { setcookie("user", $newnick, time()+3600); echo "Ieeja veiksmīga!"; } else { echo "Nepareiza parole!"; } } ?> </body> </html> Vot i man viņš visu laiku izmet teikumu "Ieeja neizdevās! Mēģini vēlreiz!" . Kur varētu būt problēma? Edited February 2, 2010 by kristapuciits Quote Link to comment Share on other sites More sharing options...
xmas12 Posted February 2, 2010 Report Share Posted February 2, 2010 mysql_close($con); <--- šis cik esdomāju parasti ir scriptabeigās, bet tev pēc mysql aiversanas uzreizir selekts :D Liec to mysql_close pasas php koda beigaas... Quote Link to comment Share on other sites More sharing options...
kristapuciits Posted February 2, 2010 Author Report Share Posted February 2, 2010 Izmainīju, nekādas atšķirības nav. Varbūt varat pateikt, kur varētu skatīties, kur varētu būt kāda nepilnība? Quote Link to comment Share on other sites More sharing options...
anonīms Posted February 2, 2010 Report Share Posted February 2, 2010 tev db neatrod tādu niku! Quote Link to comment Share on other sites More sharing options...
anonīms Posted February 2, 2010 Report Share Posted February 2, 2010 wtf? $newnick = mysql_result(mysql_query('SELECT nick FROM users WHERE nick = $_POST["nick"] '),0,0); Quote Link to comment Share on other sites More sharing options...
kristapuciits Posted February 2, 2010 Author Report Share Posted February 2, 2010 wtf? $newnick = mysql_result(mysql_query('SELECT nick FROM users WHERE nick = $_POST["nick"] '),0,0); Tur man tāda nebija. Man bija $newnick = mysql_query('SELECT nick FROM users WHERE nick = $_POST["nick"] '); ) Quote Link to comment Share on other sites More sharing options...
anonīms Posted February 2, 2010 Report Share Posted February 2, 2010 a pamēģini kā es tev iedevu Quote Link to comment Share on other sites More sharing options...
kristapuciits Posted February 2, 2010 Author Report Share Posted February 2, 2010 Ev, mož ka labāk iedodiet man gatavu login scriptu, lai varētu to izskatīt un izprast kas ir kas ? :) Quote Link to comment Share on other sites More sharing options...
anonīms Posted February 2, 2010 Report Share Posted February 2, 2010 ev, mož ieraksti googlē: php login scripts ? Quote Link to comment Share on other sites More sharing options...
2easy Posted February 2, 2010 Report Share Posted February 2, 2010 (edited) googlē pats varēsi atrast "gatavus" login skriptus (ieviešot savā lapā, var izrādīties, ka tie nemaz nav tik gatavi), taču uzskaitīju lietas, pie kā varētu "piesieties" tavā skriptā ;) 1) parolēm lieto type="password" nevis "text" <input type="password" name="pass" /> 2) sql izpilda: $result = mysql_query(...) or die(mysql_error()); tad vismaz zināsi, kāda bija kļūda, izpildot sql. paskaties manuālī šīs funkcijas. kā arī mysql_fetch_array() un mysql_result(), lai zinātu, kā paņemt selektētos datus 3) kad stringu liek iekš sql query, tas ir jāliek apostrofos. turklāt to vajag eskeipot ar mysql_real_escape_string() šādi "'" . mysql_real_escape_string($s) . "'" arī palasi manuāli par šo 4) mysql_close() vsp nevajag lietot, jo savienojums automātiski tiek aizvērts, kad skripts beidz savu darbu Edited February 2, 2010 by 2easy Quote Link to comment Share on other sites More sharing options...
edi Posted February 2, 2010 Report Share Posted February 2, 2010 Ev, mož ka labāk iedodiet man gatavu login scriptu, lai varētu to izskatīt un izprast kas ir kas ? :) ņem http://ruseller.com/lessons.php?rub=37&id=347 Quote Link to comment Share on other sites More sharing options...
2easy Posted February 2, 2010 Report Share Posted February 2, 2010 (edited) "izprast" vislabāk var, lasot programmēšanas valodas dokumentāciju aka manuāli. tur tāpat pie funkcijām ir piemēri un user komentāros vēl vairāk. gatavie skripti ne vnm pietiekami labi izskaidro, kā paši strādā protams, ja vajag ātri dabūt kko gatavu un kvalitāte does not matter, tad gatavs skripts ftw ;) Edited February 2, 2010 by 2easy Quote Link to comment Share on other sites More sharing options...
bobsters Posted February 3, 2010 Report Share Posted February 3, 2010 $newnick = mysql_query('SELECT nick FROM users WHERE nick = $_POST["nick"] '); if (!$newnick) man liekas kluda ir $_POST["nick"] labak izmanto piemeram $niks=$_POST["nick"]; un ievieto vinu $newnick = mysql_query("SELECT nick FROM users WHERE nick ='$niks'"); un ar password izdari to pasu! Quote Link to comment Share on other sites More sharing options...
anonīms Posted February 3, 2010 Report Share Posted February 3, 2010 bobsters, kā viņš var izvilkt kādu datu, ja viņam ir tīri mysq_query tikai bez fetch'a vai result? nekā Quote Link to comment Share on other sites More sharing options...
bobsters Posted February 3, 2010 Report Share Posted February 3, 2010 Es jau nerakstu lai vins izvilktu datus bet vnk lai varetu no mysql dabut ara datus ar attiecigo niku!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.