Jump to content

login script not showing up


jerryroy

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.