PHP problem with a form
Posted: Sat Jun 13, 2009 4:05 pm
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
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