WeeD* Posted January 15, 2009 Report Share Posted January 15, 2009 (edited) Labdien man problema ta ka es uztaisiju reg scriptu bet kad registrejos vins datubaze neatzimejas ka kads ir registrejies un es nevaru iejiet talak nu kr4 ielogoties nevaru! Scripts regam: <?phperror_reporting(E_ALL); include("include/config.php"); include("include/functions.php"); if(isset($_GET['darbiiba']) and $_GET['darbiiba'] == "reg") { if(!empty($_POST['vards']) and !empty($_POST['uzvards']) and !empty($_POST['epasts']) and !empty($_POST['parole']) and $_POST['parole'] == $_POST['parole_conf'] and $_POST['epasts'] == $_POST['epasts_conf']) { $vards = quote_smart($_POST['vards']); $uzvards = quote_smart($_POST['uzvards']); $epasts = quote_smart($_POST['epasts_conf']); $parole = quote_smart(md5($_POST['parole_conf'])); $bilde = "http://www.wikihow.com/images/d/d2/Face-grin.png"; mysql_query("INSERT INTO lietotaaji (vaards,uzvaards,epasts,parole,bilde) VALUES ($vards,$uzvards,$epasts,$parole,'$bilde')"); $ok = "Reģistrācija veiksmīga! Variet ielogoties!<br /><a href='index.php'>Ielogoties</a>"; } else { $kluda = "Kāds lauks/-i tika aizpildīti nepareizi!<br />"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Torrentfile Draugi!</title> <link href="stils.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="ielogoshanaas"> <a href="index.php"><img src="bildes/sisteema.gif" alt="Sistēma logo" /></a> <form method="post" action="register.php?darbiiba=reg"> <table> <?php if(isset($ok)) echo $ok; if(isset($kluda)) echo $kluda; ?> <tr><td>Vārds:</td><td><input type="text" name="vards" /></td></tr> <tr><td>Uzvārds:</td><td><input type="text" name="uzvards" /></td></tr> <tr><td>E-pasts:</td><td><input type="text" name="epasts" /></td></tr> <tr><td>E-pasts vēlreiz:</td><td><input type="text" name="epasts_conf" /></td></tr> <tr><td>Parole:</td><td><input type="password" name="parole" /></td></tr> <tr><td>Parole vēlreiz:</td><td><input type="password" name="parole_conf" /></td></tr> <tr><td></td><td><input type="submit" value="Reģistrēties" /></td></tr> </table> </form> </div> </body> </html> Scripts datubazes pieklusanai ķipa config.php : <?php //Pieslēgšanās datubāzei $db_host = 'localhost'; $db_user = 'root'; $db_password = 'ganago'; $db_name = 'sistema'; $connection = @mysql_connect($db_host, $db_user, $db_password) or die(mysql_error()); mysql_select_db($db_name, $connection); mysql_query("SET NAMES utf8"); ?><?php //Pieslēgšanās datubāzei $db_host = 'localhost'; $db_user = 'root'; $db_password = 'pass'; $db_name = 'sistema'; $connection = @mysql_connect($db_host, $db_user, $db_password) or die(mysql_error()); mysql_select_db($db_name, $connection); mysql_query("SET NAMES utf8"); ?> Scripts ielogoshanas: <?php error_reporting(E_ALL); include("include/config.php"); include("include/functions.php"); // Vajadzīgais kvērijs if(isset($_SESSION['id'])) { $id = $_SESSION['id']; $result = mysql_query("SELECT * FROM lietotaaji WHERE id=$id"); } // Ja saņem pieprasījumu IELOGOTIES if(isset($_GET['darbiiba']) and $_GET['darbiiba'] == "login") { $epasts = quote_smart($_POST['epasts']); $parole = quote_smart(md5($_POST['parole'])); $result = mysql_query("SELECT COUNT(*) FROM lietotaaji WHERE epasts=$epasts and parole=$parole"); // Izvelkam lietotāja ID $get_id = mysql_query("SELECT * FROM lietotaaji WHERE epasts=$epasts and parole=$parole"); $row = mysql_fetch_row($get_id); $id = $row[0]; // Ja šāds lietotājs pastāv if(mysql_num_rows($result) == 1) { mysql_query("UPDATE lietotaaji SET online='Y' WHERE id=$id"); $_SESSION['id'] = $id; } else { $nav = "Nepareizs epasts un/vai parole!"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>TorrentFile draugi!</title> <link href="stils.css" rel="stylesheet" type="text/css" /> </head> <body> <?php // Rādam ja nav ielogoies if(!isset($_SESSION['id'])) { ?> <div align="center" style="margin-top: 150px;"> <form method="post" action="index.php?darbiiba=login"> <?php if(isset($nav)) { echo $nav; } ?> <a href="index.php"><img src="bildes/sisteema.gif" alt="Sistēma logo" /></a> <table> <tr><td>E-pasts:</td><td><input type="text" name="epasts" /></td></tr> <tr><td>Parole:</td><td><input type="password" name="parole" /></td></tr> <tr><td></td><td><input type="submit" value="Ielogogties" /></td></tr> <tr><td></td><td align="right"><a href="register.php">Reģistrēties</a></td></tr> </table> </form> </div> <?php } // Rādam ja ir ielogojies if(isset($_SESSION['id'])) { ?> <div id="savelk"> <div id="izveelne"> <ul> <li><a href="index.php">Sākums</a></li> <li><a href="index.php?darbiiba=online">Onlainā [<?php echo mysql_result(mysql_query("SELECT COUNT(*) FROM lietotaaji WHERE online='Y' AND id!=$id"),0,'COUNT(*)'); ?>]</a></li> <li><a href="index.php?darbiiba=profils">Profils</a></li> <li><a href="index.php?darbiiba=veestules">Vēsutles</a></li> <li class="iziet"><a href="index.php?darbiiba=logout">Iziet</a></li> </ul> </div> <div id="profila_lauks"> <?php $row = mysql_fetch_assoc($result); echo "Sveiks, {$row['vaards']} {$row['uzvaards']}!<br />"; //Profila bilde $result = mysql_query("SELECT * FROM lietotaaji WHERE id=$id"); $row = mysql_fetch_assoc($result); $img = getimagesize($row['bilde']); if($img[0] > 150) { echo "<a href='{$row['bilde']}' target='_blank'><img src='{$row['bilde']}' alt='Profila bilde' width='150' /></a>"; } else { echo "<img src='{$row['bilde']}' alt='Profila bilde' />"; } ?> </div> <div id="logo"> <a href="index.php"><img src="bildes/sisteema.gif" alt="Sistēma logo" /></a><br /> </div> <div id="saturs"> <?php if(isset($_GET['darbiiba'])) { switch($_GET['darbiiba']) { case 'profils': include("switch/profils.php"); break; case 'online': include("switch/online.php"); break; case 'veestules': include("switch/veestules_inbox.php"); break; } } else { echo 'Čau !'; } ?> </div> <div id="apaksha"> <div style="padding-top: 12px">© 2009 Viktors Ganago (vknok) </div> </div> </div> <?php } ?> </body> </html> Edited January 17, 2009 by WeeD* Link to comment Share on other sites More sharing options...
anonīms Posted January 15, 2009 Report Share Posted January 15, 2009 paste.php.lv izmanto. Kāds errors metas? Link to comment Share on other sites More sharing options...
Aleksejs Posted January 15, 2009 Report Share Posted January 15, 2009 Man izskatās, ka viena problēma ir tajā, ka pirmajā failā INSERT sqlā nav teksta vērtības pēdiņās. Mainīgais $bilde vienīgais ir pēdiņās. Link to comment Share on other sites More sharing options...
WeeD* Posted January 15, 2009 Author Report Share Posted January 15, 2009 aleksej nelīdz :( ! Link to comment Share on other sites More sharing options...
anonīms Posted January 15, 2009 Report Share Posted January 15, 2009 mysql_query("INSERT INTO lietotaaji (vaards,uzvaards,epasts,parole,bilde) VALUES ($vards,$uzvards,$epasts,$parole,'$bilde')") or die(mysql_error()); Link to comment Share on other sites More sharing options...
WeeD* Posted January 16, 2009 Author Report Share Posted January 16, 2009 es pameiģināšu bet man tabulas vards ir ta : vaards uzvaards Link to comment Share on other sites More sharing options...
Aleksejs Posted January 16, 2009 Report Share Posted January 16, 2009 WeeD*, nesapratu Tavu pēdējo teikumu (pareizāk sakot, tam man ir pārāk daudz interpretāciju, lai tajās visās iedziļinātos). Ko Tu ar to domāji? Link to comment Share on other sites More sharing options...
WeeD* Posted January 17, 2009 Author Report Share Posted January 17, 2009 (edited) es izdariju taka teicāt, bet man error's ķip You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '97611ed40e4b628c98f39fdb39f9643d'')' at line 1 bet man mysql scripts lai piekļūtu bāzei ir šādi : <?php //Pieslēgšanās datubāzei $db_host = 'localhost'; $db_user = 'root'; $db_password = 'pass'; $db_name = 'sistema'; $connection = @mysql_connect($db_host, $db_user, $db_password) or die(mysql_error()); mysql_select_db($db_name, $connection); mysql_query("SET NAMES utf8"); ?><?php //Pieslēgšanās datubāzei $db_host = 'localhost'; $db_user = 'root'; $db_password = 'ganago'; $db_name = 'sistema'; $connection = @mysql_connect($db_host, $db_user, $db_password) or die(mysql_error()); mysql_select_db($db_name, $connection); mysql_query("SET NAMES utf8"); ?> Edited January 17, 2009 by WeeD* Link to comment Share on other sites More sharing options...
anonīms Posted January 17, 2009 Report Share Posted January 17, 2009 es izdariju taka teicāt, bet man error's ķip QUOTE You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '97611ed40e4b628c98f39fdb39f9643d'')' at line 1 kverijā kļūda Link to comment Share on other sites More sharing options...
Val Posted January 17, 2009 Report Share Posted January 17, 2009 pārlasi piecas reizes šo. varbūt aizies līdz pelēkajām... :> Man izskatās, ka viena problēma ir tajā, ka pirmajā failā INSERT sqlā nav teksta vērtības pēdiņās. Mainīgais $bilde vienīgais ir pēdiņās. Link to comment Share on other sites More sharing options...
WeeD* Posted January 17, 2009 Author Report Share Posted January 17, 2009 es uzliku pēdiņas uz visiem un tgd ir tāds errors ! : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'vknok@inbox.lv'',''97611ed40e4b628c98f39fdb39f9643d'')' at line 1 Link to comment Share on other sites More sharing options...
Val Posted January 17, 2009 Report Share Posted January 17, 2009 tagad izskatās, ka pa daudz... Link to comment Share on other sites More sharing options...
Aleksejs Posted January 17, 2009 Report Share Posted January 17, 2009 'vknok@inbox.lv'',''97611ed40e4b628c98f39fdb39f9643d'')' Tad, kad teicu, ka nepietiek pēdiņu, nevienā vietā neteicu, ka saliec uz dullo viskautkur pēdiņas un viss būs labi ;) Sākam ar e-pasta adresi: 'vknok@inbox.lv'' Tad nāk paroles hash vērtība: ''97611ed40e4b628c98f39fdb39f9643d'' Link to comment Share on other sites More sharing options...
WeeD* Posted January 17, 2009 Author Report Share Posted January 17, 2009 es uzliku šādi : mysql_query("INSERT INTO lietotaaji (vaards,uzvaards,epasts,parole) VALUES ('$vards','$uzvards','$epasts','$parole')") or die(mysql_error()); vnk uzraksti ka ir pareizi un es sapratishu kur man bija kļūda Link to comment Share on other sites More sharing options...
Aleksejs Posted January 17, 2009 Report Share Posted January 17, 2009 Uzraksti: $vaicajums = "INSERT INTO lietotaaji (vaards,uzvaards,epasts,parole) VALUES ('$vards','$uzvards','$epasts','$parole')"; echo '<br>'. $vaicajums . '<br>'; un parādi, ko izdrukā (iz-echo). Varbūt, ka pats arī uzreiz ieraudzīsi kļūdu (~; Link to comment Share on other sites More sharing options...
Recommended Posts