pinacoladaxb Posted April 29, 2008 Share Posted April 29, 2008 I just started using php today, so please don't use any big words on me. Anyway, I made an application that has a login system. I want it to be able to interact with a MySQL database and check if a login is correct. To do this, I know I need to use php because MySQL can only interact directly with files on the same server. Well, here's the code I wrote that checks if a username and password match: <html> <head> <title>User Check</title> </head> <? $name = $_GET['name']; $userpassword = $_GET['userpassword']; $service = "localhost"; $username = "pauliuko"; $password = "sdfsfsf"; $database = "pauliuko_games"; mysql_connect($service, $username, $password); @mysql_select_db($database) or die( "Unable to select database"); $get=mysql_query("SELECT (id) FROM users WHERE name=$user and password=$pass"); $result=mysql_query($query); echo"$result" ?> </body> </html> If the name and password match, there should be a "1" on the screen, but when I try it, the page is blank. What did I do wrong? My MySQL table has 4 columns: id, name, password, and datejoined. Could someone tell me how to fix this? I would be posting this under php help, but that forum isn't working at the moment. Link to comment https://forums.phpfreaks.com/topic/103500-checking-name-and-password-with-php/ Share on other sites More sharing options...
peranha Posted April 30, 2008 Share Posted April 30, 2008 Never start PHP with the short tags of <? always start with <?php Give that a try and let us know what happens Link to comment https://forums.phpfreaks.com/topic/103500-checking-name-and-password-with-php/#findComment-529950 Share on other sites More sharing options...
firecat318 Posted April 30, 2008 Share Posted April 30, 2008 I just usually use something with mysql_num_rows, and if the num rows of the $query are not 1, then I give them an error, or else I start the session. Link to comment https://forums.phpfreaks.com/topic/103500-checking-name-and-password-with-php/#findComment-530005 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.