hot to list the details of user?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fnleong
Forum Newbie
Posts: 18
Joined: Wed May 12, 2004 5:49 am

hot to list the details of user?

Post by fnleong »

this is the page after login

Code: Select all

<?php
<?php
	session_start();
	echo '<h1>Members only</h1>';
	if (isset($HTTP_SESSION_VARS['valid_user']))
	{
	  echo '<p>You are logged in as '.$HTTP_SESSION_VARS['valid_user'].'</p>';
	?>
	<html>
	
<HEAD><TITLE>Member Section</TITLE> 
</HEAD> 
<body> 
<div align="right"></div> 
<table width="701" border="0" align="left"> 
<tr> 

<a href="userview.php?userID = '{$_REQUEST['userID']}'">View Profile </a>
<td width="285"><div align="center"></div></td> 
</tr> 
</table> 
<p align="left"><br> 
</p> 
<div align="left"><br> 
</div> 
<p> </p> 


</body> 
</html>

<? 
exit; 
   }

	else
	{
	  echo '<p>You are not logged in..</p>';
	  echo '<p>Only logged in members may see this page.</p>';
	}
	echo '<a href="index.php">Back to main page</a>';
?>
?>








this is the link from previous page

Code: Select all

<?php
<html>
<head>
  <title>List MY Records</title>
</head>


<h1>My Profile</h1></center>
<?php

  $db = @mysql_pconnect('localhost','root');

  if (!$db)
  {
     echo 'Error: no record to database.  Please try again later.';
     exit;
  }

  mysql_select_db('mobile');


 

  $query = "select * from user where userID='{$_REQUEST['userID']}' ";
           $result = mysql_query($query);
   $num_results = mysql_num_rows($result);

 
  {
     
     echo htmlspecialchars(stripslashes($row['userID']));
     echo '</strong><br />Name: ';
     echo stripslashes($row['username']);
     echo '<br />ID: ';
     echo stripslashes($row['userID']);
     echo '<br />Email: ';
     echo stripslashes($row['Email']);
     echo '<br />password: ';
     echo stripslashes($row['password']);
     echo '</p>';
  }
mysql_close();
?>


</body> 
</html>
?>
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

you're missing one very important line

Code: Select all

<?php
 $query = "select * from user where userID='{$_REQUEST['userID']}' "; 
           $result = mysql_query($query); 
   $num_results = mysql_num_rows($result); 

//******HERE***************
while($row=mysql_fetch_row($result){ 
      
     echo htmlspecialchars(stripslashes($row['userID'])); 
     echo '</strong><br />Name: '; 
     echo stripslashes($row['username']); 
     echo '<br />ID: '; 
     echo stripslashes($row['userID']); 
     echo '<br />Email: '; 
     echo stripslashes($row['Email']); 
     echo '<br />password: '; 
     echo stripslashes($row['password']); 
     echo '</p>'; 
  } 
mysql_close(); 


?>
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

You're also embedding PHP tags - which isn't allowed. Close them ?> before ever opening another one.
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

i think thats from BBtags
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Ok :)
Post Reply