jerryroy Posted May 6, 2007 Share Posted May 6, 2007 im creating a login script but when i call to search for the username and verify to the 1 in the database then print the output nothing happens heres the code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php session_start(); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Successful Login</title> </head> <body> <font face ="tahoma"> <?php $db = mysql_connect('localhost','root','docdre') or die ("Error could not connect" .mysql_error()); mysql_select_db("user",$db) or die("Select DB error" .mysql_error()); $query = mysql_query("SELECT * FROM username WHERE username = '$_POST[unam]' " ); while ($row= mysql_fetch_array($query)) { echo "Welcome " $query<br/>; } //echo $_POST[unam]; echo date("d.m.y"); ?> </font> </body> </html> tell me if im doing something wrong cuz everything works up to the echo statement in the while loop Link to comment https://forums.phpfreaks.com/topic/50210-login-script-not-showing-up/ Share on other sites More sharing options...
benjaminbeazy Posted May 6, 2007 Share Posted May 6, 2007 try defining the user name before the query, i've had trouble like this before... trying to interpolate a request var directly in the query.. try this... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php session_start(); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Successful Login</title> </head> <body> <font face ="tahoma"> <?php $db = mysql_connect('localhost','root','docdre') or die ("Error could not connect" .mysql_error()); mysql_select_db("user",$db) or die("Select DB error" .mysql_error()); $unam = $_POST['unam']; $query = mysql_query("SELECT * FROM username WHERE username = '$unam' " ); while ($row= mysql_fetch_array($query)) { echo "Welcome {$row[VARNAME]}<br/>"; } //echo $_POST[unam]; echo date("d.m.y"); ?> </font> </body> </html> my bad, you also have to use $row[VARNAME] to return fields... so i modified the code Link to comment https://forums.phpfreaks.com/topic/50210-login-script-not-showing-up/#findComment-246485 Share on other sites More sharing options...
jerryroy Posted May 6, 2007 Author Share Posted May 6, 2007 thanks for replying so quickly an i found out my error the <br> tag was not in qoutes to be treated as a string so thank for info really apreciate it Link to comment https://forums.phpfreaks.com/topic/50210-login-script-not-showing-up/#findComment-246486 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.