...

View Full Version : log out script fix



Trki
01-11-2012, 09:16 PM
Hi guys can somebody say me why it doesn't works? of course the basic log out function works... the user will be logged out cookies and session will be destructed but ... i need delete the row from table :( and nothing happen. Somebody? ( the collums have a good name )



<?php
session_start();



require_once './includes/functions.php';
connect();

$cookies=$_COOKIE['pc'];
$zmaz = mysql_query("DELETE FROM pocitadlo_online WHERE cookies='$cookies'") or die("Udaje sa nezmazali!");

if ($zmaz) {
session_destroy();
setcookie("web_user", "", mktime(12,0,0,1, 1, 1990));
setcookie("pc", "", mktime(12,0,0,1, 1, 1990));


header("location:index.php?clanok=login");
} else { echo "Problem s zmazanim zaznamov";}

?>

Old Pedant
01-11-2012, 11:36 PM
Debug debug debug



$sql ="DELETE FROM pocitadlo_online WHERE cookies='$cookies'"

echo "<hr/>DEBUG SQL: " . $sql . "<hr/>";

$zmaz = mysql_query( $sql ) or die("Udaje sa nezmazali!");

Look at what the DEBUG shows you. Look in your DB table to see if you *do* have a record that matches the value from the DEBUG.

Trki
01-12-2012, 07:07 AM
Debug debug debug



$sql ="DELETE FROM pocitadlo_online WHERE cookies='$cookies'"

echo "<hr/>DEBUG SQL: " . $sql . "<hr/>";

$zmaz = mysql_query( $sql ) or die("Udaje sa nezmazali!");

Look at what the DEBUG shows you. Look in your DB table to see if you *do* have a record that matches the value from the DEBUG.

nothing and when i try


$sql ="DELETE * FROM pocitadlo_online WHERE cookies='$cookies'";

show: DELETE * FROM pocitadlo_online WHERE cookies='Trki'

But i have in pocitadlo_online raw where the collum has value Trki ....

echo "<hr/>DEBUG SQL: " . $sql . "<hr/>";

and the code must be good or no? because when it would be , my session would be destroyed.

fatecaresx13
01-12-2012, 07:32 AM
Hi guys can somebody say me why it doesn't works? of course the basic log out function works... the user will be logged out cookies and session will be destructed but ... i need delete the row from table :( and nothing happen. Somebody? ( the collums have a good name )



<?php
session_start();



require_once './includes/functions.php';
connect();

$cookies=$_COOKIE['pc'];
$zmaz = mysql_query("DELETE FROM pocitadlo_online WHERE cookies='$cookies'") or die("Udaje sa nezmazali!");

if ($zmaz) {
session_destroy();
setcookie("web_user", "", mktime(12,0,0,1, 1, 1990));
setcookie("pc", "", mktime(12,0,0,1, 1, 1990));


header("location:index.php?clanok=login");
} else { echo "Problem s zmazanim zaznamov";}

?>


Could you perhaps echo out sql issues/warnings?


echo mysql_error();

Just curious.

At least do the following to sanity check your self:



$cookies=$_COOKIE['pc'];
$q_ = "DELETE FROM pocitadlo_online WHERE cookies='$cookies'"
$zmaz = mysql_query($q_) or die("Udaje sa nezmazali!");

echo $q_;


That way you can see the query and perhaps run it manually to see what it returns.

Trki
01-12-2012, 07:54 AM
ah **** i found the problem.... in was in another part :/ it was automaticly inserting a new raw with this cookies ( which i think it was in this time deleted... but ... its may .... the server in one script to example:

cookies=...
delete cookies

insert into table cookies

its posible that the server took the cookies before the delete and dann he insert this " delete cookies " into the tab?

but it fixed now. ok :P



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum