I'm tryng to migrate from a myswl login system to a xml login system to save some internal process.
I have been trying to log using a xml file which is generated dinamically from a php page, but It doesn't work. Could you please take a look to the next code?
Regards
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$user_name = "";
$pwd ="";
$login = "";
$pass="";
if(isset($_POST['login'])){
session_start();
$user_name = $_POST['user_name'];
$pwd = md5($_POST['password']);
if (strlen($user_name || $pwd) < 1) { exit(header("Location:logon.php")); }
$mydata = new SimpleXMLElement('http://192.168.246.12/loginProcess/all.php', 0, true);
$login = "";
$pass = "";
$checking = $mydata->xpath('//resultado/registro[contains(username,"'.$user_name.'") and contains(pwd,"'.$pwd.'")]');
foreach($checking as $user) {
echo "Uer: {$user->username} , {$user->pwd}";
if(($_POST["user_name"] == $user->username) && ($user == $cliente->pwd)){
//set logged in
$_SESSION['logged_in'] = true;
$_SESSION['user_name'] = $user->username;
exit(header("Location: ./default.php"));
}
}
}
?>
<form method="post" action="">
<p>Username <input type="text" id ="user_name" name="user_name" size="20" /></p>
<p>Password <input type="password" id="password" name="password" size="20" /></p>
<p><input type="submit" value="Login" name="login" /></p>
</form>