tags:

views:

63

answers:

2

Hi All, 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?

+1  A: 

You cannot send HTML/Data before sending the header, so you'll have to send the javascript-alert inside the "Login.html".

Besides that you really should embrace your Javascript code with

<script type="text/javascript">
         alert('asd');
</script>
Augenfeind
A: 

How can i get the Return value like true/false

By calling PHP from Javascript

For EX

I would like to have some like

test = Callphp()

So that will will true or flase in test variable.

NewBie
outis