ANALGINS Posted September 25, 2008 Author Report Share Posted September 25, 2008 (edited) pirmkart nepatik tas ka daru ar db lapam, konkretak es tipa gribu inkludot piemeram pkp.php ieks table.php kur visi linki k stuff redzami, to taks noteikti varetu uztaisit ta ka piemeram nospiezhot uz linka izpildas konkretais select`s un paradas konkretas tabulas saturs.. <?php $con = mysql_connect("localhost","usr","usrpass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("baaze", $con); $result = mysql_query("SELECT * FROM table1"); shis ir katram no 3 failiem ierakstits, kas no mana viedokla pret db droshibu nav pienjemams.. jo nemaku savienot loginu ar parejo lapas dalju lidz galam.. pie tam liekas ka paroles nehashojas, jo P un p liekas ka viens un tas pats.. jautajums ir ka sho te if(logins_ir_korekts){include('table.php');} else { header("Location:login.php");}//vai ari neko nedarit var bez else parvest dziive? Edited September 25, 2008 by ANAL-GINS Link to comment Share on other sites More sharing options...
wap1337 Posted September 25, 2008 Report Share Posted September 25, 2008 pirmkārt vajag kveriju kas parbaudis to loginu piem. vajag kaut ko tamlīdzīgu if(isset($_GET['logins']) == $res) {include table.php;} Link to comment Share on other sites More sharing options...
ANALGINS Posted September 25, 2008 Author Report Share Posted September 25, 2008 un to spraust login_success.php pirms redirekte uz nakamo lapu vai visas lapas ? Link to comment Share on other sites More sharing options...
wap1337 Posted September 25, 2008 Report Share Posted September 25, 2008 nesapratu? Link to comment Share on other sites More sharing options...
ANALGINS Posted September 25, 2008 Author Report Share Posted September 25, 2008 kura isti vieta butu tas koda gabals jaiestumj ? un kas isti butu jaieraksta login vieta ? kkads $username vai kas ? Link to comment Share on other sites More sharing options...
wap1337 Posted September 26, 2008 Report Share Posted September 26, 2008 (edited) Mja omg ,tu kačāji kādu login skriptu , vai kā? vai pats taisīji? p.s. http://www.phpeasystep.com/workshopview.php?id=6 Edited September 26, 2008 by wap1337 Link to comment Share on other sites More sharing options...
X ID Posted September 26, 2008 Report Share Posted September 26, 2008 Koda arhitektūra, kas nāk ar pieredzi. config_inc.php <? $db=(object)array( "host"=>"localhost", "user"=>"", "pass"=>"", "name"=>"", ); // paareejie suudi session_start(); ?> page_inc.php // te čekojam sesijas un skatamies, ko inklūdot index.php <? include("config_inc.php"); include("functions_inc.php"); mysql_connect($db->host,$db->user,$db->pass)or die("Database error"); mysql_select_db($db->name)or die("Database error"); ?> <html> <head> ... </head> <body> <? include("page_inc.php"); ?> </body> </html> Link to comment Share on other sites More sharing options...
ANALGINS Posted September 26, 2008 Author Report Share Posted September 26, 2008 (edited) koda lielo pusi nosperu no kada tuta, un sho to pieliku klat no citurienes.. kam butu jabut ieks functions_inc.php? noraditam tabulam kas jainkludo ? vispar tas 1337 links ir tas no kurienes esmu nograbis to kodu.. Edited September 26, 2008 by ANAL-GINS Link to comment Share on other sites More sharing options...
X ID Posted September 26, 2008 Report Share Posted September 26, 2008 functions_inc.php manā kodā tika inklūdots piemēra pēc, tur varētu atrasties visādas funkcijas, lai tev katrā failā atsevišķi nav jāraksta funkcijas. Link to comment Share on other sites More sharing options...
wap1337 Posted September 26, 2008 Report Share Posted September 26, 2008 analgins tad kāpēč pilnībā visu neizskatīti? Man lieekas,ja visu izskatītu , tu varetu visu sataisīt! Link to comment Share on other sites More sharing options...
ANALGINS Posted September 26, 2008 Author Report Share Posted September 26, 2008 nu kr4 ta 4as tabulas 1 tabula "auth" kura ietverti visi logini usei parejas 3 tabulas ar mainigajiem, ierpu izmeriem n stuff... ir nepilnigs php kods, kuru vaig pielabot.. ta lai ielogojoties redz visas tabulas(spiezhot uzlinkiem) bet kad nav ielogojies un spiezh uz linkiem nevar atvert piemeram pkp.php.... vaig teiksim 4o leet failu, caur kuru varetu labot/dzest konkrets3 tabulas... tipa (aizmirsu ka tiesi sauc) nu kr4 ka uzspiez uz izvelnes lodzinja izvelas starp 3 tabulam kuras velas editot.. un tad ievada infu, teiksim izvelas pkp bazi un ievada atiecigas riepas n sttuff.. tas ir vis ko vaig.. Link to comment Share on other sites More sharing options...
X ID Posted September 26, 2008 Report Share Posted September 26, 2008 Nesapratu gandrīz neko. Problēma ir ar lietotājiem vai kautkādu datu labošanu? Link to comment Share on other sites More sharing options...
ANALGINS Posted September 27, 2008 Author Report Share Posted September 27, 2008 (edited) ar abiem ar loginiem ir ta ka ja neielogojas un uzraksta table.php var redzet tas saturu, un tad jau atkrit dajebkada tolka no logina.. to vaig nofixot.. es varetu iedot db un kodu ko esmu uzmocijis lidz shim un tad varbutas kads labvelis varetu pasmieties par manam kludam, un varbutas pateikt/izlabot tas ? Edited September 27, 2008 by ANAL-GINS Link to comment Share on other sites More sharing options...
wap1337 Posted September 27, 2008 Report Share Posted September 27, 2008 tu gribi laikām tā ka if ($ir_ielogojies == 1){ print 'tev ir pieej'; }else {print 'tev nav pieej';} Link to comment Share on other sites More sharing options...
ANALGINS Posted September 27, 2008 Author Report Share Posted September 27, 2008 nu vis jau buutu zaibis, javien es saprastu sho kodu if ($ir_ielogojies == 1){ print 'tev ir pieej'; }else {print 'tev nav pieej';} es nesaprotu kas jaliek ieks $ir_ielogojies, parejais algoritms itka butu saprotams varbutas tu varetu papetit esoso kodu un pateikt ? savadak man tumsha bilde.. Link to comment Share on other sites More sharing options...
X ID Posted September 27, 2008 Report Share Posted September 27, 2008 Pie ielogošanās, kad tu salīdzini klienta ievadītos datus ar datubāzē esošajiem datiem... pozitīva rezultāta gadījumā tev ir jāieseto kautkāds globāls mainīgais, kuram jāsatur lietotāja identifikators (visbiežāk tā būs sesija). Tālāk pārbaudi vai šis mainīgais ir iesetots un korekts. Link to comment Share on other sites More sharing options...
ANALGINS Posted September 28, 2008 Author Report Share Posted September 28, 2008 (edited) pienjemu ka tas ir shis koda gabals.. if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } tad man butu jaraksta shadi ? if ($count==1){ print 'tev ir pieeja'; }else {'print 'tev nav pieej';} shito kodu iebaroju, un tagad netieku gudrs kapec pie logina mani redirekte uz index un nelaizh ieksa.. tiklidz iznjem ara ta vis aiziet.. kods ieks forsham lapam <?php if($count == 1){include('dailrade.php');} else { header("Location:error.html");}//vai ari neko nedarit var bez else ?> bet ka ielogojas ta met uz error lapu.. WTF? Edited September 28, 2008 by ANAL-GINS Link to comment Share on other sites More sharing options...
wap1337 Posted September 28, 2008 Report Share Posted September 28, 2008 Man liekas tev vajag kaut ko tādu: if ( session_register("myusername"); session_register("mypassword"); ){print 'tev ir pieeja'; }else {'print 'tev nav pieej';} Link to comment Share on other sites More sharing options...
ANALGINS Posted September 28, 2008 Author Report Share Posted September 28, 2008 sakuma blava par lieku ; bet pec tam Parse error: parse error, unexpected T_STRING in \AppServ\www\pkp\table.php on line 5 Link to comment Share on other sites More sharing options...
wap1337 Posted September 28, 2008 Report Share Posted September 28, 2008 iekopē visu līdz 5 rindai! Link to comment Share on other sites More sharing options...
ANALGINS Posted September 28, 2008 Author Report Share Posted September 28, 2008 pirmas 7as rindas <?php include("checklogin.php"); if ( session_register("myusername"); session_register("mypassword"); ){print 'tev ir pieeja'; }else {'print 'tev nav pieej';} Link to comment Share on other sites More sharing options...
wap1337 Posted September 28, 2008 Report Share Posted September 28, 2008 (edited) <? session_start(); if(!session_is_registered(myusername)){ print 'tev nav pieej'; } ?> <html> Talak kam te vajag but,kad ir pieej </html> Pamēģini iebāzt šito Tu gribi kaut ko tādu?: 1. 2. Edited September 28, 2008 by wap1337 Link to comment Share on other sites More sharing options...
X ID Posted September 28, 2008 Report Share Posted September 28, 2008 wap1337, iesaku pašam saprast, ko tu dari un pēctam citiem nedot līkus kodus. ANAL-GINS, es jau teicu - autorizējot lietotāju iestādi globālu mainīgo ar lietotāja identifikatoru un pēc tam pārbaudi vai mainīgais ir iesetots un atbilst patiesībai. Pie ielogošanās, kad esi salīdzinājis ievadītos datus ar datubāzi, es darītu kkā tml PHP <? function make_authid(){ $key=md5(time()+rand(10000,99999)); $sql="SELECT COUNT(*) AS c FROM `users` WHERE auth_id='".mysql_real_escape_string($key)."'"; $res=mysql_query($sql); $row=mysql_fetch_object($res); return $row->c>0?make_authid():$key; } $authid=make_authid(); mysql_query("UPDATE `users` SET auth_id='".mysql_real_escape_string($authid)."' WHERE id='".intval($uid)."'"); setcookie("authid",$authid,null,"/"); ?> Kautkādā globālā failā (kurš tiek visur inklūdots), paskatamies vai ir cepums, ja ir tad izselektējam no datubāzes lietotāja datus, kur auth_id ir $_COOKIE['authid'] Link to comment Share on other sites More sharing options...
wap1337 Posted September 28, 2008 Report Share Posted September 28, 2008 Man kautkā liekas ka viss kas viņām ir vajadzīgs ir jau kodā, bet viņš grib visu sarežģīt Link to comment Share on other sites More sharing options...
ANALGINS Posted September 28, 2008 Author Report Share Posted September 28, 2008 nu ja ir tad ludzu izlabojat, jo wap kodi nav stradajusi, vienigi izvada ka nav pieejas, un parejo izvada vienalga.. xid censos izprast ko tu saki, bet parcik manas zinasanas nav tik spidosas es to realizet nevaru cik zinu mana koda nav nekadi cepumi .. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now