-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
  • 109
  • 1
  • 2
  • 3
    Questions on Server Fault must be about managing information technology systems in a business environment. Questions about development, testing and development tools may be asked on Stack Overflow. – masegaloeh Sep 27 '15 at 01:01
  • I vote to reopen this question, because on my opinion, it shouldn't have been closed, but migrated to stackoverflow.com. Thus, I start a vote to reopen it, and after that a new vote for migrate it to the SO. – peterh Nov 02 '15 at 16:32

1 Answers1

1

Web server tend to download instead of execution when it didn't recognize the file type.

First make sure you have installed php5module and enabled. You can check from command line:

$ a2enmod -l

actions alias auth_basic authn_file authz_host authz_groupfile authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl socache_shmcb userdir reqtimeout authn_core mcrypt mod_rewrite php5 authz_core

Then also check your httpd.conf or default-server.conf and make sure it includes AddType

DocumentRoot "/srv/www/htdocs"

DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3

AddType application/x-httpd-php .php .php3 .php4 .php5

Don't forget to restart your web server for Ubuntu: sudo service apache2 restart