Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to read the contents of a php file using javascript

So let's say I have a form tag like so. And I want to print the contents of the file to screen using JavaScript. How do I go about doing that?

<form action="/missions/basic/3/index.php" method="post">
    <input type="hidden" name="file" value="file.php" />
    <input type="password" name="password" />
    <br />
    <br />
    <input type="submit" value="submit" />
</form>

What I want is to use the alert() function to show the contents of file.php, even though the contents are hidden.

like image 704
Gary Theurpe Avatar asked Dec 10 '25 10:12

Gary Theurpe


1 Answers

What I want is to use the alert() function to show the contents of file.php, even though the contents are hidden.

You just can't. Don't waste your time :)

If your web server is configured correctly it will never output PHP code even if you could request that from JavaScript.

You can grab and show the output of a PHP file on the client but not its source code like that, unless there is a mess up or it is by design.

like image 120
Hanky Panky Avatar answered Dec 12 '25 23:12

Hanky Panky



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!