This one has got me tearing my hair out.
I've got a form the outputs to the same page to collect username and password. i then want to compare this input with the username and password in an XML file.
i can echo the values from the POSTs and the XML file and they look exactly the same on screen but when i try to compare them they will not give out a match.
i've been using the Zend framework (for the first time i may add).
Code: Select all
<div id="welcome">
<h1>Please login</h1>
<form method="post" action ="login.php">
<table align="center">
<tr>
<td align="right">
username:
</td>
<td align="left">
<input type="text" name="username">
</td>
</tr>
<tr>
<td align="right">
password:
</td>
<td align="left">
<input type="text" name="password">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="submit">
</table>
<?php
// include auto-loader class
require_once 'Zend/Loader/Autoloader.php';
// register auto-loader
$loader = Zend_Loader_Autoloader::getInstance();
// read XML config file
$user = new Zend_Config_Xml('user.xml');
$a = $user->username;
$b = $user->password;
//check if username and password match the xml file
if($_POST['username'] == $a && $_POST['password'] == $b){
echo "Welcome " . $user->firstname . " " . $user->lastname;
}
else {
echo "Either Username or password has been entered incorrectly";
}
echo "<br>POST - " . $_POST['username'];
echo "<br>xml - " . $user->username;
echo "<br>POST - " . $_POST['password'];
echo "<br>xml - " . $user->password;
?>