user371803
user371803

Reputation: 41

form trying to open php file

I'm new to php and I have the following form in my html file:

<form id="loginForm" action="login.php" method="post">
    <label for="username">Username:</label>
    <div>
        <input type="text" name="username" maxlength="255"/>
    </div>
    <label for="password">Password:</label>
    <div>
        <input type="password" name="password" maxlength="255"/>
    </div>
    <div class="buttonDiv">
        <input type="submit" name="loginButt" value="Login"/>
    </div>          
</form>

Why does it try to open my php file when I try to run it? Open as in firefox opens a window asking me if I want to save or open the file.

Thanks

Upvotes: 3

Views: 5131

Answers (4)

Subodh Poudel
Subodh Poudel

Reputation: 35

Save the HTML file with the extension .php. This will do it.

Upvotes: 0

Wifi Cordon
Wifi Cordon

Reputation: 226

Probably you don't have the php server running. The form page displays correctly in the browser since the page file is a normal html file.

You'll see that if you try to execute the php file directly from the browser the same thing will happen.

An other thing that could be happening is that, in case you are using apache server, you are not loading the php apache module.

Upvotes: 0

Raphael Caixeta
Raphael Caixeta

Reputation: 7846

Make sure that you have PHP enabled. May sound stupid, but it's probably the solution.

Upvotes: 0

Artefacto
Artefacto

Reputation: 97845

Because you're opening the HTML file directly in your browser or your web server does not handle PHP files.

For Windows, you might want to try this.

Upvotes: 4

Related Questions