Jump to content

Recommended Posts

Right, hi all first post here, be nice :)

 

okay, what i want to do is show the username field when a particular person has logged in. heres my code

 

<?php
// Connects to your Database
mysql_connect("localhost", "username", "pword") or die(mysql_error());
mysql_select_db("username") 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
{
//logged in details at end of page
}
}
}
else

//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Instant-Traffic.info - The Worlds Best Traffic Exchange Site</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>
<body>

<div id="wrapper">

<div id="header">
<div id="logo">
	<h1><a href="index.php">Instant-Traffic.info</a></h1>
</div>
<!-- end #logo -->
<div id="menu">
	<ul>
		<li class="active"><a href="index.php">Home</a></li>
		<li><a href="members.php">Control Panel</a></li>
		<li><a href="logout.php">Logout</a></li>
	</ul>
</div>
<!-- end #menu -->
</div>
<!-- end #header -->
<div id="page">
<div id="content">
	<div style="margin-bottom: 10px;"></div>
	<div class="post">
		<h1 class="title">Thanks For Logging In</h1>
		<div class="entry">
				<p><strong>Thanks for logging in <?php echo $username['username'] ?> 
				</strong></p>
				<p><strong>For now, this a temporary page whilst the autosurf pages and control panel is made, please be patient during this process. Thank you for co-operation.</strong></p>
        </div>
		<div class="meta"></div>
	</div>
</div>
<!-- end #content -->
<div id="sidebar">
	<div id="sidebar-bgtop"></div>
	<div id="sidebar-content">
		<div id="sidebar-bgbtm">
		<ul>
			<li id="search">
				<h2>Links</h2>
				<form method="get" action="">
					<fieldset>
					</fieldset>
				</form>
				<ul>
				  <li></li>
			  </ul>
		    </li>
			<li>
			  <ul>
			    <li></li>
					<li></li>
			  </ul>
			</li>
		</ul>
	</div>
	</div>
</div>
<!-- end #sidebar -->
<div style="clear:both; margin:0;"></div>
</div>
<!-- end #page -->

</div>

<div id="footer">
<p>© 2008. All Rights Reserved.</p>
</div>
<!-- end #footer -->
</body>
</html>

 

obvs the username and pword is filled out in the actual code. the problem is, it only shows the first letter of the username.

 

Link to comment
https://forums.phpfreaks.com/topic/175236-showing-username-from-mysql-database/
Share on other sites

ive tried $info['username'] first but it didnt work.

 

as for the second part i tried $_COOKIE['username'] but it didnt work either....

 

also how can i mod this to redirect to URL listed a file name htp?

 

$redirect="http://www.eg.net";
if(preg_match(array('/Firefox/','/Safari/'),$_SERVER['HTTP_USER_AGENT']))!=1) header("Location: ".$redirect);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.