CGCX Posted April 25, 2009 Report Share Posted April 25, 2009 (edited) Beidzot man izdevas izveidot login lapu, bet es velos uzzinat kodu kas veiktu sadu darbibu ejot uz lapas linku piem http://majaslapa.oo.lv paradisies lapa login bet ja jau esi ielogojies tad vina neradas (radas tikai tad kad Nēsi ielogojies) un nebutu iespejams tikt citas lapas ieksa~ ka draugie**.*vLudzu palidziet busu pateicigs Edited April 25, 2009 by CGCX Quote Link to comment Share on other sites More sharing options...
bubu Posted April 25, 2009 Report Share Posted April 25, 2009 To dara ar visparastāko if konstrukciju: if (lietotājs ir ielogojies) { echo "parastais lapas saturs"; } else { echo "login forma"; } Quote Link to comment Share on other sites More sharing options...
CGCX Posted April 25, 2009 Author Report Share Posted April 25, 2009 Njam bet es tiesi velejos uzzinat kur tas ir jaliek un kur var atrast -> if (lietotājs ir ielogojies){ echo "parastais lapas saturs"; } else { echo "login forma"; } Quote Link to comment Share on other sites More sharing options...
m8t Posted April 25, 2009 Report Share Posted April 25, 2009 (edited) //index.php lapa, so lapu nevar redzet bez ielogosanas <? include("login_check.php"); ?> un te bus index.php lapas saturs, viss ko velies. //login_check.php, parbaudam vai lietotajs ir ielogojies, ja ir ielogojies, lai turpina, ja nav ielogojies, metam uz login <? session_start(); if(!isset($_SESSION['lietotajvards']) || (trim($_SESSION['lietotajvards']))== '') { header( 'Location: login.php' ); exit(); } ?> //login.php include("login_check2.php"); login lapas saturs te, vajadzetu ari ielikt lietu, kad ielogojas, tad $_SESSION['lietotajvards'] = $_POST['lietotajvards']; //login_check2.php, parbaudam vai lietotajs ir ielogojies, ja ir ielogojies, metam uz index sis fails satur to pasu, kas ir login_check.php, tiaki visu japarveido preteji, to lausu izdarit tev Ceru ka palīdzēju -Shizo0 Edited April 25, 2009 by m8t Quote Link to comment Share on other sites More sharing options...
CGCX Posted April 25, 2009 Author Report Share Posted April 25, 2009 Es nesapratu tos pedejos 2 ar pirmajiem 2 vis kartiba ka iet uz linku iemet lapa bet es nesapratu //login.phpinclude("login_check2.php"); login lapas saturs te, vajadzetu ari ielikt lietu, kad ielogojas, tad $_SESSION['lietotajvards'] = $_POST['lietotajvards']; piem tad login.php jabut ta ? <? include("login_check2.php"); ?> vai jatstaj vecais kods un kkur jaiestarpina ? un par to otru tiaki visu japarveido preteji, to lausu izdarit tev ludzu vari izveidot ka tas ir ,jo es noteikti kko ne ta daru Quote Link to comment Share on other sites More sharing options...
m8t Posted April 25, 2009 Report Share Posted April 25, 2009 (edited) Iedošu tev savu login scriptu, sapratu ka tev tāds nav //login.php include("config.php"); $ad = $_GET['id']; <? if ($ad == 1) { if(!session_id()) session_start(); if(isset($_POST['login']) && isset($_POST['pass'])) { $conn=mysql_connect($host, $user, $pwd, $pict) or die(mysql_error()); mysql_select_db($db, $conn); $_POST['login']=mysql_real_escape_string(strip_tags(trim($_POST['login']))); $_POST['pass']=mysql_real_escape_string(strip_tags(trim($_POST['pass']))); $q=mysql_query("SELECT * FROM TAVAMYSQLTABULATE WHERE username='{$_POST['login']}' AND password='{$_POST['pass']}'",$conn) or die(mysql_error()); if(mysql_num_rows($q) > 0) { $_SESSION['lietotajvards'] = $_POST['login']; header('Location: index.php'); function checkLogin(){ if($_SESSION['login'] = $_POST['lietotajvards']){ }else{ return false; } } $logged_in = checkLogin(); } else { $teksts='Error'; } mysql_close($conn); } echo $teksts; } else { ?> <form method="post" action="login.php?id=1" > Lietotājvārds:<br /> <input type="text" name="login" /><br /> Parole:<br /> <input type="text" name="pass" /><br /> <input type="submit" value="Ienākt" /><br /> <p align="center"><a href="reg.php">Reģistrēties</a></p> </form> <? } ?> //config.php, uzliec host, username, password, database pec saviem mysql uzstadijumiem $host = "host"; $user = "username"; $pwd = "password"; $db = 'database'; $conn = mysql_connect($host, $user, $pwd, $pict) or die(mysql_error()); mysql_select_db($db, $conn) or die(mysql_error()); Ja vajag vēl ko, prasi - centīšos palīdzēt. Ps.- Tas include("login_check.php"); , vai include("login_check2.php"); var būt jebkurai lapai virspusē. include("login_check.php"); - norādīs uz to ka bez login nevarēs apskatīt lapu, include("login_check2.php"); - norādīs uz to, ka tikai neielogojies varēs apskatīt lapu, tikai login_check2.php tev būs jāuzstāda maliet savādāk nekā login_check.php. ps2.- Te būs maziņš DEMO, manam skriptam (nav uzlikts ka tie kas ir ielogojusies nevar apskatit login/reg lapu) - http://draugi.comze.com/lpp/ Username: 123, Pass: 123 Edited April 25, 2009 by m8t Quote Link to comment Share on other sites More sharing options...
CGCX Posted April 26, 2009 Author Report Share Posted April 26, 2009 (edited) nezinu ka isti, nesapratu "laikma paraks sarezgiti priex manis " Edited April 26, 2009 by CGCX 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.