Possible Duplicate:
Call php from javascript and return an array from php to Javascript function
i am having an php code for verification of User in XML
For Eg: ValLogin.php
<?php
$userName = $_REQUEST["username"];
$password = $_REQUEST["password"];
$iCount = 0;
$loginArray = array();
$xml = simplexml_load_file("Logintest.xml");
for ($i=0;$i<2;$i++)
{
foreach($xml->Username[$i]->attributes() as $a => $b)
{
$loginArray[$iCount] = $b;
$iCount++;
}
if($userName == $loginArray[0] && $password == $loginArray[1])
{
header("Location: EHP_Configuration.html");
return ;
}
$iCount = 0;
}
echo "<SCRIPT LANGUAGE='javascript'>alert('asd')</SCRIPT>";
header("Location: Login.html");
?>
HTML
<form method = "post" action = "ValLogin.php">
</form>
echo does not work as expected. it directly shows redirect to Login
How can i get the message invalid username/Login?
SimpleXMLElement::xpath()(php.net/manual/en/simplexmlelement.xpath.php) rather than looping. Looking up a user will take 1 line:$xml->xpath("//Username[@User='$username' and @Password='$password']")