I read some manuals and looked on stackoverflow but still my code doesn't work.
I have this PHP code
if(!file_exists("entrant/".$lgn.".xml")){
$myfile = fopen("entrant/".$lgn.".xml", "w") or die("Nebylo možné vytvořit soubor!");
$txt = "<?xml version='1.0' encoding='UTF-8'?>"
. "<root>"
. "<pwd>$pwd</pwd>"
. "<pointsXY></pointsXY>"
. "<pointsSBIRANI></pointsSBIRANI>"
. "<triedXY>0</triedXY>"
. "<triedSBIRANI>0</triedSBIRANI>"
. "</root>";
fwrite($myfile, $txt);
fclose($myfile);
$_SESSION['usr'] = $_POST['usr-lgn'];
header('Location: content/stats.php');
} else {
$xml=simplexml_load_file("entrant/".$lgn.".xml") or die("Nemůžu přečíst soubor");
if($xml['pwd'] === $pwd) {
$_SESSION['usr'] = $_POST['usr-lgn'];
header('Location: content/stats.php');
} else {
echo "<script>alert('Zadal/a jste špatné heslo! ');</script>";
}
}
Part that isn't working is
} else {
$xml=simplexml_load_file("entrant/".$lgn.".xml") or die("Nemůžu přečíst soubor");
if($xml['pwd'] === $pwd) {
$_SESSION['usr'] = $_POST['usr-lgn'];
header('Location: content/stats.php');
} else {
echo "<script>alert('Zadal/a jste špatné heslo! ');</script>";
}
}
XML file that I have created
<?xml version='1.0' encoding='UTF-8'?><root><pwd>test</pwd><pointsXY></pointsXY><pointsSBIRANI></pointsSBIRANI><triedXY>0</triedXY><triedSBIRANI>0</triedSBIRANI></root>
So basically when user has file I am trying to get his password. But I cant get him it always echo that alert. I am from Czech so you may not understand it but I don't have nothing to do with it I suppose so :) Thanks for all help