thenewprogrammer
New Member
- Messages
- 45
- Reaction score
- 0
- Points
- 0
Having problems outputing information from a table called login. Database information is correct and users are in there under field 'username' .Noticed everyone's opinions on whats wrong with code havnt worked so far. Output is always User profile which is direct text in the head. When signed in. Since im new to php and dont understand everything wondering if the username has to be in the url for this to work? The username when i log in at first puts the username in the url for main page. But when i clicked profile the username isnt in the url anymore. Does it have to be in the url for this to work? if so how do i do it for this page.
Code:
<?
$user = $_GET['user'];
session_start();
if(!isset($_SESSION['user'])){
header("Location: http://thenewprogrammer.x10hosting.com");
}
$dbhost = "localhost";
$dbname = "*****";
$dbuser = "*****";
$dbpass = "*****";
mysql_connect($dbhost, $dbuser, $dbpass) or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die("Could not select the database: ".mysql_error());
$username = mysql_real_escape_string($user);
$query = "SELECT * FROM login WHERE username ='".$username."'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
?>
<html>
<head>
User Profile
</head>
<body>
<?php echo($username); ?>
<br />
<?php print_r($row); ?>
</body>
</html>