ziedinjsh Posted October 18, 2009 Author Report Share Posted October 18, 2009 Aizgāja mans variants? nop Notice: Undefined variable: _SESSION in /home/produc/public_html/mp3/1/profile.php on line 9 bet kapēc tā Quote Link to comment Share on other sites More sharing options...
waplet Posted October 18, 2009 Report Share Posted October 18, 2009 pieliec augšā session_start(); pēc <? un varbūt nevēlies padalīties ar visu kodu, iespējams tev viss iet un tu tikai esi kko sajaucis, man tādas aizdomas Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 18, 2009 Author Report Share Posted October 18, 2009 (edited) jā tikoes arī par to aizdomājos.. pieliku session_start(); un aizgāja Paldies! :) uztaisīju logout.php bet bet kad meoģinu izlogoties parāda šādu Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /home/produc/public_html/mp3/1/logout.php on line 2 Warning: Cannot modify header information - headers already sent by (output started at /home/produc/public_html/mp3/1/logout.php:2) in /home/produc/public_html/mp3/1/logout.php on line 3 logout.php: <?php session_destroy(); header("Location:index.php"); ?> betman liekas, ka kkas trūkst :D un kāds varētu izskatīties kods kurš atpazīst vai ir ielogojies vai nē.. piem man ir šādi: <div id='left'> include "login.php"; include "profile.php"; </div> protams, ka rādīsies abi divi, bet kā varētu panāk sādu efektu: <div id='left'> if(member){ include "profile.php"; }else{ include "login.php"; } Edited October 18, 2009 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
waplet Posted October 18, 2009 Report Share Posted October 18, 2009 session_destroy(); ieliec pašā apakšā Quote Link to comment Share on other sites More sharing options...
waplet Posted October 18, 2009 Report Share Posted October 18, 2009 if(isset($_SESSION['User_ID'])){ print "tu esi ielogojies"; }else{ print "ielogojies lai redzētu, to ko redz arī nemirstīgie"; } Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 18, 2009 Author Report Share Posted October 18, 2009 tā, to atpazīšanu uztaīsīju.. laikam, ka strādā if ($_SESSION['user_ID']){ include "user/profile.php"; }else{ include "user/login.php"; } Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 18, 2009 Author Report Share Posted October 18, 2009 logout izskatās sādi <?php header("Location:../index.php"); session_destroy(); ?> bet nu met topašu ārā Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted October 18, 2009 Report Share Posted October 18, 2009 session_destroy() manuprāt neizpildās pēc header. <?php ob_start(); session_start(); session_destroy(); unset($_SESSION); header("Location:../index.php"); ob_flush(); ?> Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 18, 2009 Author Report Share Posted October 18, 2009 Paldies! Šis strādā! Vienīgi tagad nospiež vienu reizi login pogu viņš neielogojās.. ielogojās tikai ar otro reizi kad nospiež pogu kas varētu būt pa vainu? :? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 19, 2009 Author Report Share Posted October 19, 2009 Vēljoprojām nevaru saprast kapēc ielogojas tikai 2 x nospiežot login pogu Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted October 19, 2009 Report Share Posted October 19, 2009 Varbūt Tev tomēr ir kādi minējumi, kāda "sazvērestības teorija", kāpēc tā? ;) Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 19, 2009 Author Report Share Posted October 19, 2009 es jau štukoju.. mošk kodā nav kaut kas vai arī ar seozām :? <?php $status = (isset($_GET['status'])) ? $_GET['status'] : ''; if(isset($_POST['login'])){ $email = strip_tags($_POST['email']); $password = strip_tags($_POST['password']); $query = sprintf("SELECT ID FROM users WHERE email = '%s' AND password = '%s' LIMIT 1;", mysql_real_escape_string($email), md5($password)); $result = mysql_query($query) or die(mysql_error); if(mysql_num_rows($result) != 1){ echo "<span style='color:#ff0000'>bad login</span>"; }else{ $row = mysql_fetch_assoc($result); $_SESSION['user_ID'] = $row['ID']; } } echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>"; echo "<table><tr>"; echo "<td>email</td><td><input type='text' name='email'></td>"; echo "</tr><tr>"; echo "<td>password</td><td><input type='password' name='password'></td>"; echo "</tr><tr>"; echo "<td></td><td><input type='submit' name='login' value='Login'></td>"; echo "</tr><tr>"; echo "<td><a href='register.php'>Register?</a></td><td><a href='lost.php'>Lost password?</a></td>"; echo "</tr></table>"; ?> Quote Link to comment Share on other sites More sharing options...
waplet Posted October 19, 2009 Report Share Posted October 19, 2009 pēc šit~ā $_SESSION['user_ID'] = $row['ID']; pieliec redirektu uz index.php Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 19, 2009 Author Report Share Posted October 19, 2009 Paldies waplet :) 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.