title: PHP login script - User profile loop
body: <p>The system I'm using doesn't have an option to view other users' profiles (Only your own) (By other users' profiles I mean something like <code>http://domain.com/profile.php?user=USERNAME</code>). However, the original one, has it.
  I want to implant it in the new system so I created a new php file for the profile.</p>
  
  <p>I downloaded this login system:<br>
  <a href="http://tympanus.net/codrops/2009/09/16/php-login-system-reloaded-v1-1/" rel="nofollow">http://tympanus.net/codrops/2009/09/16/php-login-system-reloaded-v1-1/</a></p>
  
  <p>It is a custom version of this system:<br>
  <a href="http://jpmaster77forum.conceptbb.com/t1-php-login-system-with-admin-features-download" rel="nofollow">http://jpmaster77forum.conceptbb.com/t1-php-login-system-with-admin-features-download</a></p>
  
  <p>Here is the original <code>userinfo.php</code> code:</p>
  
  <pre><code>&lt;?
  include("include/session.php");
  ?&gt;
  
  &lt;html&gt;
  &lt;title&gt;Jpmaster77's Login Script&lt;/title&gt;
  &lt;body&gt;
  
  &lt;?
  /* Requested Username error checking */
  $req_user = trim($_GET['user']);
  if(!$req_user || strlen($req_user) == 0 ||
     !eregi("^([0-9a-z])+$", $req_user) ||
     !$database-&gt;usernameTaken($req_user)){
     die("Username not registered");
  }
  
  /* Logged in user viewing own account */
  if(strcmp($session-&gt;username,$req_user) == 0){
     echo "&lt;h1&gt;My Account&lt;/h1&gt;";
  }
  /* Visitor not viewing own account */
  else{
     echo "&lt;h1&gt;User Info&lt;/h1&gt;";
  }
  
  /* Display requested user information */
  $req_user_info = $database-&gt;getUserInfo($req_user);
  
  /* Username */
  echo "&lt;b&gt;Username: ".$req_user_info['username']."&lt;/b&gt;&lt;br&gt;";
  
  /* Email */
  echo "&lt;b&gt;Email:&lt;/b&gt; ".$req_user_info['email']."&lt;br&gt;";
  
  /**
   * Note: when you add your own fields to the users table
   * to hold more information, like homepage, location, etc.
   * they can be easily accessed by the user info array.
   *
   * $session-&gt;user_info['location']; (for logged in users)
   *
   * ..and for this page,
   *
   * $req_user_info['location']; (for any user)
   */
  
  /* If logged in user viewing own account, give link to edit */
  if(strcmp($session-&gt;username,$req_user) == 0){
     echo "&lt;br&gt;&lt;a href=\"useredit.php\"&gt;Edit Account Information&lt;/a&gt;&lt;br&gt;";
  }
  
  /* Link back to main */
  echo "&lt;br&gt;Back To [&lt;a href=\"main.php\"&gt;Main&lt;/a&gt;]&lt;br&gt;";
  
  ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And this is my new <code>profile.php</code>:</p>
  
  <pre><code>&lt;?php
  include('config/db_con.php');
  include('config/config.php');
  $page = 'profile';
  include('header.php');
  require_once("php/core.php");
  
  $objCore = new Core();
  
  $objCore-&gt;initSessionInfo();
  $objCore-&gt;initFormController();
  
      mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");
  $get_email = $objCore-&gt;getSessionInfo()-&gt;getUserInfo('email');
  $get_flname = "SELECT * FROM `users` WHERE email = '$get_email'";
  $res = mysql_query($get_flname) or die(mysql_error());
  $rows = mysql_fetch_array($res);
  $gemail_hash = md5( strtolower( trim( "$get_email" ) ) );
  $req_user = trim(strtolower(str_replace(" ", "", $rows['flname'])));
  ?&gt; 
  &lt;div class="content"&gt;
      &lt;div class="left"&gt;
          &lt;div class="top_box" style="margin-top:0px;"&gt;
              &lt;p&gt;&lt;h90&gt;Profile: &lt;?php echo $rows['flname']; ?&gt;&lt;/h90&gt;&lt;?php echo $req_user; ?&gt;&lt;/p&gt;
          &lt;/div&gt;
          &lt;div class="box_pad"&gt;
              &lt;div class="box" style="border-bottom:1px solid #dbdbdd;"&gt;  
                  &lt;?php if($objCore-&gt;getSessionInfo()-&gt;isLoggedIn()){ ?&gt;
                          &lt;img class="gravatar" src="http://www.gravatar.com/avatar/&lt;?php echo $gemail_hash; ?&gt;?d=mm" /&gt;
                          &lt;h1&gt;&lt;?php echo $rows['flname']; ?&gt;&lt;/h1&gt;&lt;br /&gt;
                          &lt;a href="editaccount.php"&gt;[Edit Account]&lt;/a&gt;
                          &lt;? if($objCore-&gt;isAdmin()) ?&gt;
                              &lt;a href="admin.php"&gt;[admin]&lt;/a&gt;
                          &lt;a href="php/corecontroller.php?logoutaction=1"&gt;[Logout]&lt;/a&gt;
                          &lt;? }else{ ?&gt; 
                          blabla test
                          &lt;? } ?&gt;
  
         &lt;?php unset($objCore); ?&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="right"&gt;
          &lt;? include('ad.php'); ?&gt; 
      &lt;/div&gt; 
  &lt;/div&gt;
  &lt;?include('footer.php');?&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>It doesn't work 'cause when trying to access other users' profiles, I see mine again.
  How is the <code>file.php?user=USERNAME</code> url pattern is defined?</p>
  
  <p>Thank you so much!
  I really need this and I couldn't find anything on Google, since I didn't really know what to search for.
  Sorry if there's information lacking, I tried to be as descriptive as possible.</p>