FT3 Posted October 19, 2009 Report Share Posted October 19, 2009 Labdien. Krč ir tada lieta uzkodeju kodu bet ir viena problema kad ienak caur login systemu rada tik pirma lietotaja datus ka lai izlabot ? <?php include("db_connect.php"); $query = "SELECT * FROM members"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); echo "Username:"; echo $row['username']; echo "<br />"; echo "Your password:"; echo $row['password']; echo "<br />"; echo "Your E-mail:"; echo $row['email']; echo "<br />"; echo "Your name:"; echo $row['name']; ?> <br> [<a href="logout.php">Logout</a>] Ierriekš paldies ;]] Quote Link to comment Share on other sites More sharing options...
waplet Posted October 19, 2009 Report Share Posted October 19, 2009 Ar to ka GIGN'ā atbildēju nepietiek? Quote Link to comment Share on other sites More sharing options...
FT3 Posted October 19, 2009 Author Report Share Posted October 19, 2009 nesanak savienot kodu ;]] Quote Link to comment Share on other sites More sharing options...
zinatnieks Posted October 19, 2009 Report Share Posted October 19, 2009 <?php include("db_connect.php"); $query = "SELECT * FROM members"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "Username:"; echo $row['username']; echo "<br />"; echo "Your password:"; echo $row['password']; echo "<br />"; echo "Your E-mail:"; echo $row['email']; echo "<br />"; echo "Your name:"; echo $row['name']; } ?> <br> [<a href="logout.php">Logout</a>] Quote Link to comment Share on other sites More sharing options...
FT3 Posted October 19, 2009 Author Report Share Posted October 19, 2009 (edited) zinatnieks , nepareiz taja ko tu iedevi kodu rada visus userus, bet man vjg lai raditu tikai ta ar ko tu ienaici :/ bet ir viens variants kuru man iedeva "daviskrex" $_SESSION['user_id'] = $row['id']; $id = $_SESSION['user_id']; SELECT * FROM users WHERE id=$id bet es viņu nevaru savienot ar savu kodu ;/ Edited October 19, 2009 by FT3 Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted October 19, 2009 Report Share Posted October 19, 2009 Nevis nepareizi, bet tu nepareizi izteicies. Tu nemaz nēesi pateicis kā tu glabā ienākušā lietotāja datus - sesijas? Kukiji? $sql = "SELECT * FROM users WHERE id = " . $_SESSION["uid"]; Quote Link to comment Share on other sites More sharing options...
zinatnieks Posted October 19, 2009 Report Share Posted October 19, 2009 Nu pēc pirmā posta es tā arī sapratu, ka tu gribi lai rāda visus, ja jau selectē visus. Tādā ga'dijumā kāpēc tev ir $query = "SELECT * FROM members"; Nav nekādas nepieciešamības selectēt visus lietotājus.. Kad logojas iekšā sistēmā, pēc veiksmīgas autorizācijas iemet $_SESSION['user_id'] = $row['id'], kur $row['id'] satur konkrētā lietotāja id. Tālāk jau tu varēsi to $_SESSION izmantot lai selectētu tikai tā lietotāja datus kurš ir ielogojies, respektīvi: $query = "SELECT * FROM members WHERE id=".$_SESSION['user_id'].""; Quote Link to comment Share on other sites More sharing options...
waplet Posted October 19, 2009 Report Share Posted October 19, 2009 Es to neiedevu :D es teicu, ka tev vajag ciklu, lai izvadītu visus lietotāju, to kodu iedeva tev "daviskrex" , kurš arī acīmredzami ir viens no tiem, kas nespēj saprast tavu jautājumu Quote Link to comment Share on other sites More sharing options...
FT3 Posted October 19, 2009 Author Report Share Posted October 19, 2009 mans checklogin.php fails <?php include("db_connect.php"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:index_success.php"); } else { echo "Wrong Username or Password"; } ?> mans user_info.php fails <?php include("db_connect.php"); $query = "SELECT * FROM members WHERE id=".$_SESSION['member_id'].""; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); echo "Username:"; echo $row['username']; echo "<br />"; echo "Your password:"; echo $row['password']; echo "<br />"; echo "Your E-mail:"; echo $row['email']; echo "<br />"; echo "Your name:"; echo $row['name']; ?> <br> [<a href="logout.php">Logout</a>] un ka lai tos kodus apvieno ;/ Quote Link to comment Share on other sites More sharing options...
waplet Posted October 19, 2009 Report Share Posted October 19, 2009 Tu gribi lai index'ā tev rāda datus par tevi? Quote Link to comment Share on other sites More sharing options...
FT3 Posted October 19, 2009 Author Report Share Posted October 19, 2009 (edited) ja taja index_success.php faila Edited October 19, 2009 by FT3 Quote Link to comment Share on other sites More sharing options...
waplet Posted October 19, 2009 Report Share Posted October 19, 2009 parādi , kas atrodas tajāindex_success.php failā Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted October 19, 2009 Report Share Posted October 19, 2009 session_register() nevajadzētu izmantot. Tā vietā var rakstīt tā $_SESSION["username"] = $username Un paroles arī nevajag glabāt sesijā. Tā vietā pieglabā lietotāja id un pēc tā arī dabūsi šobrīdējā lietotāja datus. Quote Link to comment Share on other sites More sharing options...
FT3 Posted October 19, 2009 Author Report Share Posted October 19, 2009 <? include("db_connect.php"); session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /> <title></title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id=border> <div id=content> <div id=logo></div> <div id=navigation> <ul> <li><a href="index_success.php">Главная</a></li> <li><a href="index_success.php">Информация</a></li> <li><a href="index_success.php">Файловы Архив</a></li> </ul> </div> <div id=line> </div> <div id=page> <td class="row1" align="left" width="100%"> <font size="2px"> <?php include("allusers.php"); ?> <span class="gensmall"> <div class="hrr"> </div><div style="background-color: #888;"><font size="1px"> </div> </font> :D </span> </td> </tr> <BR /></div> <div id=panel-l> <style> .img_border { padding:1px; border:1px solid #021a40; background-color:#fffff; } table.center {margin-left:auto; margin-right:auto;} </style> <table class='center' border='0' cellspacing='0' cellpadding='0'> <h2>Сервер</h2> :D </table> <h2>ПУСТО</h2> :D </div> <div id=panel-r> <h2>Вход | Инфо</h2> <?php include("user_info.php"); ?> <br> <h2>Чят</h2> :D <br> <h2>Статистика</h2> :D </div> </div> </div> <br> <center> <img src="http://www.lighttpd.net/images/xcache.png" /> <img src="http://www.lighttpd.net/php_power.png" /> <br> :D </center> <br> </body> </html> Quote Link to comment Share on other sites More sharing options...
Cibiņš Posted October 19, 2009 Report Share Posted October 19, 2009 (edited) 1) Kurš <style> tagus liek iekš body??? 2) NAV noslēgts tags kaut kur vai arī tagu secība kautkur iet šķērsām. Padziļinātāk nepētīju. Edited October 19, 2009 by Cibiņš 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.