I took some of my old code and am putting it into a tester site, I'm creating a log in and have set up a form, a php file to check if the username/password exsist and a sql database.
The problem I am having is that every time I press the submit button on my form the browser, instead of moving to the php page and running its code, tries to download the file. I'm not sure if this is to do with my coding or not.
heres the form:
<form action= "Login.php" method="post">
Login:
<br />
<input name="txtusername" type="text" value="" />
<br />
<br />
<input name="txtpassword" type="password" value="" />
<br />
<br />
<input type="submit" value="Log In" />
</form>
Heres the PHP it links to:
<?php
$link = mysql_connect('localhost','root','');
mysql_select_db('gametest',$link);
$sql = "SELECT * FROM userlogin WHERE username='";
$sql = $sql . $_POST[txtusername] . "' and password='" . $_POST[txtpassword] . "';";
$result = mysql_query($sql,$link);
echo "<head><meta HTTP-EQUIV='REFRESH' content='0; url=GameTestHome.html'></head>";
?>
I just dont see why it downloads perhaps its just how long I've been staring at it? Once I get this working i can move onto securing it and make my other pages!
Thanks for any help
Aravona
PHP problem with a form
Moderator: General Moderators
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: PHP problem with a form
Try: at the top of Login.php.
Code: Select all
header('Content-disposition: inline');Re: PHP problem with a form
I've put this in, same error occurs, its still trying to download the login.php file instead of running its code :S
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: PHP problem with a form
If you download the file can you see PHP code?
Re: PHP problem with a form
Yes you can, opens as a notepad file.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: PHP problem with a form
OK, what's happening then is that the PHP isn't being executed at all. You can't write any PHP to solve that problem. This is most likely to be an issue of server configuration. Perhaps your placing the file in a directory where PHP code isn't executed? If your using a hosting company consult their documentation.
Re: PHP problem with a form
I am just using WAMP server. I reinstalled the latest one today and it's saved in the www drive. Just realised I wasn't using local host to test. My god I'm a dumbarse, too long a day! Thanks, without you saying that wouldn't have realised.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: PHP problem with a form
Ha ha! Glad we sorted it out.