1

I am making an authentication form on HTML and trying to link it up with PHP. The HTML code is

<!DOCTYPE html>
<html>
<head>
    <title>Authorized logged in</title>
</head>

<div id = "adminBoard">

<form method = "POST" action = "auth.php">
<input type="text" class = "credentialInputL" name="loginInput" value = "login" size = 30>
<input type="password" class = "credentialInputP" name="passwordInput" value = "pass" size = 30>
<input class="loginLogoutButton" type = "submit" value = "Sign in" name="loginLogout">
</form>
</div>

</body>
</html>

The corresponding auth.php file (that I made to ensure basic working of POST method before expanding it) is:

<?php
    if (isset($_POST['loginInput']) && isset($_POST['passwordInput'])){
        $username = $_POST['loginInput'];
        $password = $_POST['passwordInput'];
        echo "The username is :" . $username;
        echo "The password is :" . $password;
    }
?>

But when I open the HTML file in chrome, and click on the Sign in button, then the auth.php file simply gets downloaded. No action takes place. Both the html and php files are in the same folder.

Am I missing some syntax / operator / method?

harshvardhan
  • 765
  • 13
  • 32
  • Possible duplicate of http://stackoverflow.com/questions/18422140/apache-is-downloading-php-files-instead-of-displaying-them – Jesse Sep 27 '15 at 00:47
  • Essentially what is happening is the server does not know how to display your php files and is sending them to application/octet-stream. A possible htaccess problem or php problem itself. More information about your server is needed in this specific scenario as this is not code related. – Jesse Sep 27 '15 at 00:48
  • But I am running it on my localhost, not on Apache or any server! – harshvardhan Sep 27 '15 at 00:49
  • This is not coding related. Please see http://serverfault.com/ to address these types of issues – Jesse Sep 27 '15 at 00:49
  • 1
    **But I am running it on my localhost, not on Apache or any server!** you need a server configured to run php, for example, apache. – Pedro Lobito Sep 27 '15 at 01:20
  • "But I am running it on my localhost, not on Apache or any server!" ... well there's your problem... –  Sep 27 '15 at 04:05
  • Thank you. Now I figure it out :) – harshvardhan Sep 27 '15 at 09:19

0 Answers0