tags:

views:

45

answers:

3

Hi, 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

+2  A: 

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.

Artefacto
i'm rendering the html template throuhg php and twig
+1  A: 

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

Raphael Caixeta
+1, webserver isn't configured to handle PHP files.
Adam Backstrom
i can run other php scripts
Mind posting the content of your login.php file then?
Raphael Caixeta
http://pastie.org/1026141It's in the pastie.
On line 60 you have $passowrd defined into the function, according to your variable definitions it should be $password. Try updating that and see if it works. If it does, there's something wrong with your error reporting setup.
Raphael Caixeta
that didn't do it but thanks for pointing that out
Last but not least, are you sure you have the correct file paths on the require_once?
Raphael Caixeta
yea those are all right. i have all my php files in the same dir to make things easy as i learn php
A: 

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.

Wifi Cordon
if i do localhost/home.php it renders the page just fine btw i'm using wamp already
Is the form page a php file or is it a html file?if it's a html file, are you requesting the page to the server?for example http://localhost/formPage.htmlor are you loading it on the browser directly as c:\\your\path\to\formPage.html?If so. Then request it to the server. After that php should kick in to interpreter the php scripting.Did you already checked on wamp if php module for apache is loaded? right click on wamp icon, go to "Apache" menu, go to "Apach Modules" or something like that. There look for php module and see if its loaded. Restart apache service
Wifi Cordon
I'm using Twig with PHP so my php files call a twig function which renders the html page i.e $template = $twig->loadTemplate('login.html'); echo $template->render(array());