ded Posted January 28, 2009 Share Posted January 28, 2009 Even when I put in a correct Username/Password, I receive the followin: Username/Password Combination Invalid. Click the back button on your browser and re-enter Here is the code index.php <form method=post action="post.php" enctype="multipart/form-data"> <table border="0" align="center" style="width: 40%; border: 1px solid #000099;background-color: #d0cfb4" > <tr> <td style="font-weight: bold; color: #000099; font-size: 100%; text-align: right;background-color: #d0cfb4;">User Name</td> <td style="background-color: #d0cfb4;"><input name="username" type="text" maxsize="25" style="width: 150px; font-size: 90%;"> <tr> <td style="font-weight: bold; color: #000099; font-size: 100%; text-align: right;background-color: #d0cfb4;">Password</td> <td style="background-color: #d0cfb4;"><input name="password" type="password" style="width: 150px; font-size: 90%;"></td> </tr> <tr> <td colspan="2" style="text-align: center;background-color: #d0cfb4;"><input type="submit" name="Login" value="Sign-In" style="color: #000099;"></td> </tr> </table> </form> post.php <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $username = $_POST['username']; $password = $_POST['password']; $dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("database"); $query = "SELECT * FROM `table` WHERE `username` = $username and `password` = $password"; $result = mysql_query($query,$dbh) or die("Username/Password Combination Invalid. Click the back button on your browser and re-enter"); .............. Can anyone see what i am missing? Thanks in advance, DED Quote Link to comment Share on other sites More sharing options...
bluesoul Posted January 28, 2009 Share Posted January 28, 2009 your use of or die() doesn't make sense in this context. It'll still return a result, only with 0 rows, if the query is built correctly. But your query needs to look like this: $query = "SELECT * FROM table WHERE username = '$username' and password = '$password'"; $result = mysql_query($query,$dbh) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
ded Posted January 28, 2009 Author Share Posted January 28, 2009 I see what you mean..... I am running into another problem. Notice: Undefined index: area in /home1/public_html/webpage/post.php on line 14 php ini_set ("display_errors", "1"); error_reporting(E_ALL); $username = $_POST['username']; $password = $_POST['password']; $dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("database"); $query = "SELECT * FROM table WHERE username = '$username' and password = '$password'"; $result = mysql_query($query,$dbh) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $area = $_GET['area']; Area is a field name in Table Quote Link to comment Share on other sites More sharing options...
bluesoul Posted January 28, 2009 Share Posted January 28, 2009 php ini_set ("display_errors", "1"); error_reporting(E_ALL); $username = $_POST['username']; $password = $_POST['password']; $dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("database"); $query = "SELECT * FROM table WHERE username = '$username' and password = '$password'"; $result = mysql_query($query,$dbh) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $area = $row['area']; $_GET is typically used for variables in a query string at the end of a page. index.php?do=foo would assign $_GET['do'] = "foo"; Quote Link to comment Share on other sites More sharing options...
ded Posted January 28, 2009 Author Share Posted January 28, 2009 Duh.....I get a lot of brain freezes....lol Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.