Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Login to apache server using a web page

I have this code right here:

<html>
    <body style="color:white;background-color:#222222">
        <center>
            <br>
            <input type="text" id="username"> Username</input>
            <br>
            <input type="text" id="password"> Password</input>
            <br><br>
            <button onclick="test()">Submit</button>
            <p id="url"/>

            <script type="text/javascript">
                function test(){
                    var userInput = document.getElementById("username").value;
                    var userPass = document.getElementById("password").value;
                    document.getElementById("url").innerHTML = encodeURI('http://'+userInput+':'+userPass+'@'+window.location.hostname+':81/Home/');
                }
            </script>
        </center>
    </body>
</html>

It outputs an url that works. It logs me into my password-protected folders when I specify the right password. Only problem, I want the "Submit" button to automaticly redirect me to the specified page instead of showing me the url.

I tried everything. Please help. Thanks.


1 Answers

Please check this:

function test(){
    var userInput = document.getElementById("username").value;
    var userPass = document.getElementById("password").value;
    location.href = encodeURI('http://'+userInput+':'+userPass+'@'+window.location.hostname+':81/Home/');
}
like image 77
Rehmat Avatar answered Nov 19 '25 22:11

Rehmat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!