0
我嘗試從myswl登錄系統遷移到xml登錄系統以保存一些內部進程。使用xml和simplexmlelement的PHP登錄
我一直在嘗試使用一個xml文件,它是從一個php頁面dinamiically生成的,但它不起作用。你可以看看下一個代碼嗎?
問候
<?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>
請不要拿在文件中平原的密碼,這讓你大開未來的問題,使用'password_hash'和'password_verify'爲https://開頭計算器.com/questions/30279321/how-to-use-password-hash –
Hi @NigelRen,我會看看這個,謝謝 –