SkyD Posted November 7, 2005 Report Share Posted November 7, 2005 (edited) Labdien. Tātad sākšu ar to, ka gribētu, lai jūs man pasakat, kas man te nav pareizs. Forma: <form name="FormName" action="pievienot.php" method="post"> <input name="logins" type="text" value=""> <input name="parole" type="text" value=""> <input type="submit" value="Send"> Logina un paroles pievienošana (pievienot.php): <? $hostname="localhost"; $mysql_login="root"; $mysql_password=""; $db = mysql_connect("$hostname", "$mysql_login" , "$mysql_password") or die("Neder!"); if (!(mysql_select_db("tests",$db))) { echo "nav kaartiibaa ar DB<br>"; } if($q){ echo "<br>";} $q == mysql_query("INSERT INTO admini (logins,parole) VALUES ('$logins','$parole')")or die(mysql_error()); if($q) { echo "Pievienots!"; } ?> <? error_reporting(E_ALL); ?> Un nolasīšana (lasisana.php): <?php $connection = mysql_connect ("localhost","root", "") or die ("Nevar savienot!"); $db = mysql_select_db ("tests",$connection) or die ("Nevar savienot ar datu bāzi!"); $sql_query = "SELECT * FROM admini"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { while($row = mysql_fetch_row($result)) { echo (": $row[4]"); } } else { echo "bāzē nekā nav.."; } ?> <? error_reporting(E_ALL); ?> Nu lieta tāda, ka pie nolasīšanas rāda vairākus punktinjus.. (::::) <-- taadus.. Un kad pievieno veel klāt kautko, + veel punktinji. Edited November 7, 2005 by SkyD Link to comment Share on other sites More sharing options...
Vebers Posted November 7, 2005 Report Share Posted November 7, 2005 $row[4] nav tuksh lauks ? Link to comment Share on other sites More sharing options...
SkyD Posted November 7, 2005 Author Report Share Posted November 7, 2005 Nu lieku $row[2], $row[1], $row[0] arii punktinji.. Link to comment Share on other sites More sharing options...
Vebers Posted November 7, 2005 Report Share Posted November 7, 2005 un kaa ar register_globals ? Labaak lieto $_POST['logins'] un $_POST['parole'] pie ievietoshanas DB Link to comment Share on other sites More sharing options...
SkyD Posted November 7, 2005 Author Report Share Posted November 7, 2005 (edited) Un register_global jabuut off?? 22 rinda: $q == mysql_query("INSERT INTO admini (logins,parole) VALUES ('$_POST['logins']','$_POST['parole']')")or die(mysql_error()); un error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in d:\lapa\a.php on line 22 Edited November 7, 2005 by SkyD Link to comment Share on other sites More sharing options...
Vebers Posted November 7, 2005 Report Share Posted November 7, 2005 Jaa, ieteicams. $logins = $_POST['logins']; $parole = $_POST['parole']; $q == mysql_query("INSERT INTO admini (logins,parole) VALUES ('$logins','$parole')")or die(mysql_error()); Link to comment Share on other sites More sharing options...
SkyD Posted November 7, 2005 Author Report Share Posted November 7, 2005 eu veciit izdevās.. Tnx.. =]]~~ a kaa lai es izdzeeshu no tabulas aaraa ierakstus? Link to comment Share on other sites More sharing options...
Vebers Posted November 7, 2005 Report Share Posted November 7, 2005 (edited) mysql_query("DELETE FROM tabulas_nosaukums WHERE lietotajs='blabla'"); P.S. WHERE var nenoraadiit ja gribi izdzeest visus ierakstus Edited November 7, 2005 by MakaTaNaw Link to comment Share on other sites More sharing options...
SkyD Posted November 8, 2005 Author Report Share Posted November 8, 2005 (edited) Hmm... Vajag taa, ierakstot loginu un paroli, lai paarbauda vai ir pareizs vai nepareizs.. Logins un parole atrodas datu baazee.. MYSQL! <? $hostname="localhost"; $mysql_login="root"; $mysql_password=""; $db = mysql_connect("$hostname", "$mysql_login" , "$mysql_password"); if (!(mysql_select_db("admin",$db))) { echo "nav kaartiibaa ar DB<br>"; } else { $q = mysql_query("SELECT COUNT(*) FROM admini WHERE logins='$logins' AND parole=MD5('$parole')"); list($skaits) = mysql_fetch_row($q); if ($skaits==0) { echo 'tu esi launais haxorz'; } else { echo 'welcome to mai page!'; } } ?> Kas nav kaartiibaa?? Toch zinu kaads ir lietotājvārds un parole ir MD5 kodeeta... Kad rakstu iekshaa, un nospiezhu OK pasaka tu esi launais haxorz... Bet vajadzeetu welcome to mai.... Un tabulaa admini ir viens ieraksts, proti tas logins un parole, kura ir pasleepta zem MD5... Edited November 8, 2005 by SkyD Link to comment Share on other sites More sharing options...
bubu Posted November 8, 2005 Report Share Posted November 8, 2005 Neredzu vietu, kur tiek definēts $logins un $parole mainīgie. Uzliec error_reporting(E_ALL) un tad tikai tālāk runāsim ;) Link to comment Share on other sites More sharing options...
v3rb0 Posted November 8, 2005 Report Share Posted November 8, 2005 nupat tak bija posts kuraa strings "SELECT COUNT(*) FROM admini WHERE logins='$logins' AND parole=MD5('$parole')" partapa par shitaadu kveriju SELECT COUNT(*) FROM admini WHERE logins='$logins' AND parole=MD5('$parole') Link to comment Share on other sites More sharing options...
goldy Posted November 8, 2005 Report Share Posted November 8, 2005 padomaa kas tavaa skriptaa ir: $logins, $parole un ko tu domaa ar so list($skaits) = mysql_fetch_row($q); Link to comment Share on other sites More sharing options...
bubu Posted November 8, 2005 Report Share Posted November 8, 2005 padomaa kas tavaa skriptaa ir:... list($skaits) = mysql_fetch_row($q); Un kas tam vainas? (man tādas aizdomas, ka tas ir manis iemests kautkur koda fragments paņemts ;) Link to comment Share on other sites More sharing options...
SkyD Posted November 8, 2005 Author Report Share Posted November 8, 2005 (edited) aa .. nu nodefineeju.. tag ok.. Edited November 8, 2005 by SkyD Link to comment Share on other sites More sharing options...
SkyD Posted November 8, 2005 Author Report Share Posted November 8, 2005 A ja es gribu, lai peec tam vareetu nospiest podzinju IZIET, tad man jalietot session ?? Link to comment Share on other sites More sharing options...
Recommended Posts