PHP and mySQL Linking Problems
Alright so I created a user login mixing PHP and mySQL. It's pretty simple, they create account, it sends the login and other info to a database table called "users". After they login they are taken to members.php.
Here's the script for that page:
PHP Code:
<html>
<head>
<title>LCF Games</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
// Connects to your Database
mysql_connect("XXXXX", "braden_gaming", "XXXXX") or die(mysql_error());
mysql_select_db("braden_gaming") or die(mysql_error());
//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{ header("Location: login.php");
}
//otherwise they are shown the admin area
else
{
echo "Admin Area<p>";
echo "<a href=logout.php>Logout</a>";
}
}
}
else
//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
?>
<iframe src="http://gamercard.xbox.com/<?php echo $tag; ?>.card" scrolling="no" frameBorder="0" height="140" width="204"><?php echo $tag; ?></iframe>
Test 1, 2 ,3
</body>
</html>
My problem is with this part:
PHP Code:
<iframe src="http://gamercard.xbox.com/<?php echo $tag; ?>.card" scrolling="no" frameBorder="0" height="140" width="204"><?php echo $tag; ?></iframe>
Where you see <?php echo $tag; ?> I'm wanting to grab a particular information about the logged-in user from a field called "tag"... being their xbox live gamertag. This way when they navagate to the page that's what they see, their gamertag.
Now I know I have to define where to get tag somewhere previously (possibly via array?) but I'm not sure how as i just learned PHP and mySQL yesterday. So any help I could get would be great. Thanks!