...

View Full Version : ?!Username Help!?



RawliJr
06-26-2006, 06:59 PM
<? mysql_connect( 'Localhost', 'xxx', 'xxx' );
mysql_select_db( 'xxx' ); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Main Menu</title>
<style type="text/css">
html, body {
margin:0;
padding:0;
background:#000;
color:#FFF;
}
.eric {
height: 400px;
width: 200px;
border: 3px solid red;
background: #fff;
color:#FFF;
float:left;
}
.rawli {
height: 400px;
width: 200px;
border: 3px solid red;
background: #fff;
float: right;
}
</style>
</head>
<center><img src="/images/THUGKILLIN.jpg" border="0" width="444" /></a></center>
<center><h3><? print"$user[username] (#$user[id])"; ?></h3></center>
<body>
<div class="eric">
<a href="turntrick.php">Turn Tricks</a>
<br><br>
<a href=">forums.php">Forums</a>
<br><br>
<a href="getturns.php">Buy Turns</a>
<br><br>
<a href="attackrank.php">Attack Ranks</a>
<br><br>
<a href="cityr.php">City Ranks</a>
</div>
<div class="rawli">
<a href="naranks.php">National Ranks</a>
<br><br>
<a href="store.php">Corner Store</a>
<br><br>
<a href="faqs.html">Faqs</a>
<br><br>
<a href="http://www.thugkillin.urlshort.com">LogOut</a>
</div>
</body>
</html>
that is my base.php, and what im trying to do is get the username that i loged in with shows up in the browser....ex. Rawlijr(#1)


and im not sure if this will work or not?And what will i have to add to make it work if anybody knows?:thumbsup:


<? print"$user[username] (#$user[id])"; ?>



Cheers,
Rawli

lavinpj1
06-26-2006, 07:03 PM
Impossible to answer without more info. We don't know how your login system is setup. All your code shows is you connecting to the database and displaying an image.

~Phil~

RawliJr
06-26-2006, 07:07 PM
ok, ill post the login system...


<? ob_start(); ?>
<html>
<head>
<title>ThugKillin</title>
</head>
<body>
<center><img src="/images/THUGKILLIN.jpg" border="0" width="444" /></a></center>
<body bgcolor="#000" text="white">
<center>
<?

if( empty($_POST['username']) || empty($_POST['password']) )
{
echo 'Invalid username/password try again';

exit();
}

if( !preg_match('/^[a-z][a-z0-9_-]{3,31}$/i', $_POST['username']) || (strlen($_POST['password']) < 6) )

{
echo 'Invalid username/password try again!';
exit();
}

mysql_connect( 'Localhost', 'xxx', 'xxx' );
mysql_select_db( 'xxx' );

$result = mysql_query( "SELECT id FROM users WHERE username='{$_POST['username']}' AND password='{$_POST['password']}'" );
$user = mysql_fetch_assoc( $result );
mysql_free_result( $result );

mysql_close();

if( empty($user) )
{
echo 'Invalid username/password try again!';
exit();
}
header( 'Location: http://thugkillin.urlshort.com/base.php' );
$_SESSION['user_id'] = $user['id'];
?>
</center>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum