yeahz Posted October 20, 2008 Report Share Posted October 20, 2008 Kāds var izpalīdzēt saprast, kāpēc nevar ielogoties? Lūk kods priekš ielogošanās: http://paste.php.lv/8176?lang=php Kad mēģinu ielogoties tad vienkārši nekas nenotiek, lapa pārlādējas, iemet login darbībā un viss. Link to comment Share on other sites More sharing options...
Maris-S Posted October 20, 2008 Report Share Posted October 20, 2008 Uz ātru apskatoties vienu kļūdu pamanīju. "SELECT * FROM lietotaaji WHERE epasts='$epasts' and parole='$parole'" Tev nav apostrofu. Lieto mysql_error, lai redzētu kļūda, ko atgriež mysql datubāze. Link to comment Share on other sites More sharing options...
yeahz Posted October 22, 2008 Author Report Share Posted October 22, 2008 To man laikam izdevās sataisīt, bet ir nākoša problēma - kad mēģinu izlogoties tad izmet šādu erroru: Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in C:\AppServ\www\2\logout.php on line 6 Un izlogošanās skripts ir šāds: <? // Izlogoties if(isset($_GET['d']) and $_GET['d'] == "logout") { unset($_SESSION['id']); session_destroy(); } ?> Uz vēlviena problēma - ja arī es esu izlogojies, tad man parādās teksts kuram būtu jāuzrādās tikai tad kad tu esi ielogojies, lūdz šis kods: <?php if(!isset($_SESSION['id'])) { echo "<a href='logout.php?d=logout'>Iziet</a>"; } if(isset($_SESSION['id'])) { echo "neesi ielogojies"; } ?> Liels paldies ja kāds palīdzēs. Link to comment Share on other sites More sharing options...
hmnc Posted October 22, 2008 Report Share Posted October 22, 2008 unset($_SESSION['id']); tas tev nav vajadzīgs! Link to comment Share on other sites More sharing options...
andrisp Posted October 22, 2008 Report Share Posted October 22, 2008 Par pirmo problēmu - tas tāpēc, ka skriptā droši vien nav session_start(); Un otrā problēma ir tāpēc, ka ir pirmā problēma. hmnc, ar to session_destroy() vispār ir interesanti. Tas neiznīcina $_SESSION masīva saturu. session_destroy() destroys all of the data associated with the current session. It does not unset any of the global variables associated with the session, or unset the session cookie. Man vispār nav skaidrs, ko tad viņš tur īsti iznīcina. Katrā ziņā - $_SESSION = array(); does the job. Link to comment Share on other sites More sharing options...
Aleksejs Posted October 22, 2008 Report Share Posted October 22, 2008 otrā problēma ir tādēļ, ka esi sajaucis vietām pārbaudi. Ja eksistē $_SESSION['id'] - tādā gadījumā lietotājs ir ielogojies, bet ja nav, tādā gadījumā nav. Link to comment Share on other sites More sharing options...
hmnc Posted October 22, 2008 Report Share Posted October 22, 2008 Andri - a her zin, man mūžu mūžos ir strādājis destroyers un nereizi nav bijuši tādi errori. Link to comment Share on other sites More sharing options...
yeahz Posted October 22, 2008 Author Report Share Posted October 22, 2008 (edited) Nu pirmā problēma vairs nav problēma, otrā vēlaizvien pastāv. Edited October 22, 2008 by zekils Link to comment Share on other sites More sharing options...
Aleksejs Posted October 22, 2008 Report Share Posted October 22, 2008 zekil, samainīji vietām: if(!isset($_SESSION['id'])) { //Tātad nav ielogojies } if(isset($_SESSION['id'])) { //Tātad ir ielogojies } Link to comment Share on other sites More sharing options...
yeahz Posted October 22, 2008 Author Report Share Posted October 22, 2008 Tagad vienalga abos gadījumos rāda 'neesi ielogojies'. Darīju kā teici, <?php if(!isset($_SESSION['id'])) { echo "neesi ielogojies"; } if(isset($_SESSION['id'])) { echo "<a href='logout.php?d=logout'>Iziet</a>"; } ?> Link to comment Share on other sites More sharing options...
SynC Posted October 27, 2008 Report Share Posted October 27, 2008 Tev failu vajag konvertēt uz utf-8 without bom caur notepad++ Link to comment Share on other sites More sharing options...
andrisp Posted October 27, 2008 Report Share Posted October 27, 2008 SynC, kāpēc gan ? Link to comment Share on other sites More sharing options...
SynC Posted October 27, 2008 Report Share Posted October 27, 2008 (edited) Cik es atceros sesijas nedarbojas ja ir ieslēgts bom Edited October 27, 2008 by SynC Link to comment Share on other sites More sharing options...
andrisp Posted October 28, 2008 Report Share Posted October 28, 2008 SynC, bet viņam jau nav headers already sent kļūda. Mēs pat skaidri nezinam vai viņš vispār izmanto UTF-8. Link to comment Share on other sites More sharing options...
Recommended Posts