Debug the Challenge

Sandra Murphy

? [bolofecal]
5 years ago

1

Use this files to understand and debug the level, both files in same dir

index.php
`“<?php
$login = (isset($POST[‘login’]) ? $POST[‘login’] : ”);
$password = (isset($POST[‘password’]) ? $POST[‘password’] : ‘’);
?>
<!DOCTYPE html>


Intermediate 6











<?php
$doc = new DOMDocument;
$doc->preserveWhiteSpace = false;
$file = file_get_contents(“users.xml”);
$doc->loadXML($file);
        $xpath = new DOMXPath($doc);  

        $query = "//user[login/text() = '" . $login . "' and password/text() = '" . $password . "']";  

        $users = $xpath->query($query);  


        foreach($users as $user) {  
            echo '<p><strong>Welcome '.$user->childNodes[2]->textContent.'!</strong></p>';  
            foreach($user->childNodes as $node) {  
                echo $node->nodeName." - ".$node->nodeValue."<br />";  
            }  
        }  
        echo '<hr /><kbd>'.htmlentities($query).'</kbd>';  
    ?>  
</body>  

```

users.xml
<?xml version="1.0" encoding="utf-8"?> <users> <user> <login>test</login> <password>test</password> <realname>test</realname> </user> <user> <login>bolofecal</login> <password>ILikePie</password> <realname>Bolo Fecal</realname> </user> <user> <login>sandramurphylogin</login> <password>hardpassword</password> <realname>Sandra Murphy</realname> </user> <user> <login>user</login> <password>pass</password> <realname>name</realname> </user> </users>

0replies
1voice
179views
You must be logged in to reply to this discussion. Login
1 of 1

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss