Hey, I started to learn PHP Coding in the last week, and I run into a problem.
I created a Data Base using MySQL.
and i created a table.
the table looks like this :
id int(11) No auto_increment Username text No Password varchar(32) No Name text No Email text No Date text No IP text No lvl tinyint(4) No 1 exp tinyint(4) No 0 expmax tinyint(4) No 100 hp tinyint(4) No 100 hpmax tinyint(4) No 100 gold tinyint(4) No 0 align tinyint(4) No 0 mp tinyint(4) No 80 mpmax tinyint(4) No 80 Actkey varchar(40) No Activated int(1) No 0
and all works fine.
But how can i print each of those in a members only page ?
I already have a members page that works fine, but I don't know how to print each member's name , lvl , gold , etc.
ohh, and the gold, hp, hpmax, exp, expmax, mp,mpmax and align have default values.
only the Username, Password, Name and Email are taken from the registeration form.
And I say again, I already have the whole system, but I want that in the members page that looks like this :
<?php session_start();
if($_GET['set'] > 0)
{
if($_SESSION['whattoclose'] == NULL)
{
$_SESSION['whattoclose'] = $_GET['set'];
} else {
$_SESSION['whattoclose'] = $_SESSION['whattoclose'] . '|' . $_GET['set'];
}
}
if($_GET['undo'] > 0)
{
if(!empty($_SESSION['whattoclose'])){
$_SESSION['whattoclose'] = str_replace("|".$_GET['undo'] , "" , $_SESSION['whattoclose']);
$_SESSION['whattoclose'] = str_replace($_GET['undo'] , "" , $_SESSION['whattoclose']);
}
}
function showTitle($id)
{
$title = array(
"Navigation",
"Login information",
);
$data = $_SESSION['whattoclose'];
$not = explode( "|" , $data );
if(!in_array( $id , $not ))
{
echo '<a href="member.php?set='.$id.'">close</a> - ';
echo $title[$id-1];
} else {
echo '<a href="member.php?undo='.$id.'">open</a> - ';
echo $title[$id-1];
}
}
function checkIt($id)
{
$data = array(
'<p><a href="logout.php">Logout</a></p>
<p><a href="member.php?change=password">Change Password</a></p>
<p><a href="member.php?change=email">Change Email</a></p>
<p><a href="member.php?change=account">Close account</a></p>',
'<p>Welcome to the members only page '.$_SESSION['s_name'].'!</p>
<p>You are logged in as '.$_SESSION['s_username'].' from the IP address '.$_SERVER['REMOTE_ADDR'].'</p>',
);
$str = $_SESSION['whattoclose'];
$not = explode( "|" , $str );
if(!in_array( $id , $not ))
{
echo '<div class="table">';
echo $data[$id-1];
echo '</div>';
}
}
?>
<div class="header">
<? showTitle(1) ?>
</div>
<? checkIt(1) ?>
<br>
<div class="header">
<? showTitle(2) ?>
</div>
<? checkIt(2) ?> Each member will see all things like [name, username, e-mail, lvl, exp, expmax, hp, hpmax, gold, align , mp and mp max.
Can some one please help me ?
Thanks, HazardZ.
