Jump to content


Help in php


5 replies to this topic

#1 HazardZ

    Young Padawan

  • Members
  • Pip
  • 3 posts

Posted 07 May 2005 - 06:18 AM

EDIT : Sry I didn't saw that there is a PHP Forum, please transfer.



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.

#2 soyunlocofl

    Young Padawan

  • Members
  • Pip
  • 70 posts
  • Location:FL

Posted 07 May 2005 - 08:27 AM

Hi, i think it should be better if you use varchar for your username, name, email and not a text. For the date i think you should use Datetime. I could help displaying the data using perl since i have little knowledge using php.

#3 HazardZ

    Young Padawan

  • Members
  • Pip
  • 3 posts

Posted 07 May 2005 - 09:46 AM

Ohh, ok.


But can u explain a bit more ?

I'm kind of a rookie in PHP.

#4 Jaymz

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 4,104 posts

Posted 07 May 2005 - 09:51 AM

HazardZ, on May 7 2005, 08:18 AM, said:

EDIT : Sry I didn't saw that there is a PHP Forum, please transfer.
Done.

#5 soyunlocofl

    Young Padawan

  • Members
  • Pip
  • 70 posts
  • Location:FL

Posted 07 May 2005 - 06:57 PM

Add me to aim cuban4life1818 and i be glad to help you in anything i can.

#6 HazardZ

    Young Padawan

  • Members
  • Pip
  • 3 posts

Posted 08 May 2005 - 12:59 AM

Hmm... I don't have Aim, but I do use ICQ.


do you have ICQ ?

If you do please add me : 6813697





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users