hya can someone take a look at this coding its for view profile and it has a on/offline on it when i log in it shows offline and nothing echos through see pic

c6bd41d477df56cf7543dd36a623ada0

<?php 
include("config/db_connect.php");

$profid     = $_GET['profid'];

// code for user details
$query      = mysql_query("select * from user where user_id = '".$profid."' ");
$fetch_user = mysql_fetch_array($query);

$user_image = mysql_query("select * from user_images where user_id ='".$fetch_user['user_id']."' and main_image = '1' ");
$fetch_image= mysql_fetch_array($user_image);

if($_GET['gen']!= "") 
{
    $_SESSION['user_gender'] = $_GET['gen'];
}
$info_query = mysql_query("select * from user_info where user_id = '".$fetch_user['user_id']."' ");
$fetch_info = mysql_fetch_array($info_query);

 //code start here for last visit to see profile
if($_SESSION['userid']!='')
{
    if($_SESSION['userid']!="$profid")
    {
        $check_visit = mysql_query("select * from visitor where visitor_id = '".$_SESSION['userid']."' and user_id = '".$profid."' ");
        if(mysql_num_rows($check_visit)>0)
        {
            mysql_query("update visitor set visit_date=now() where user_id='".$profid."'and visitor_id='".$_SESSION['userid']."'");
        }else {
            mysql_query("insert into visitor set user_id = '".$profid."' , visitor_id = '".$_SESSION['userid']."' , visit_date = now() , status = '1' ");
        }
    }
}
 //code end here for last visit to see profile
?>
<html>
<head>
    <title>View Profile</title>
  <script type="text/javascript">
function del_prompt(form1,comb)
{
if(comb=='favorite'){
        form1.action = "favorites.php";
        form1.submit();
}
else if(comb=='Active'){
form1.action = "gallery-active.php";
        form1.submit();
}

}

</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="stickytooltip.js"></script>
<link rel="stylesheet" type="text/css" href="stickytooltip.css" />
<script type="text/javascript">
$(document).ready(function(){
  $("Div#arrowdon").click(function(){
    $("Div#proinfod").removeClass('pro_div');
    $("Div#proinfod").addClass('pro_divdown');
    //$("Div#proinfod").animate({height:-520},"slow");
  });

  $("Div#arrowup").click(function(){
    $("Div#proinfod").removeClass('pro_divdown');
    $("Div#proinfod").addClass('pro_div');
    //$("Div#proinfod").animate({height:520},"slow");
  });

});
</script>
  </head>
<body>

            <?php 
        // Fetch user randam for display on top
        $query_rand = mysql_query("select * from user where user_id!='".$profid."' and user_gender ='".$_SESSION['user_gender']."' ORDER BY RAND() LIMIT 0,7"); ?>
        <?php while($query_rand_row = mysql_fetch_array($query_rand)) { 
$user_imagerd = mysql_fetch_array(mysql_query("select * from user_images where user_id = '".$query_rand_row['user_id']."' and main_image = '1' "));
?>
          <?php if($user_imagerd['user_image']!='') { ?>
          <a href="viewprofile.php?profid=<?php echo $query_rand_row['user_id'];?>"><img src="images/user_images/smallthumb/<?php echo $user_imagerd['user_image'];?>" border="0" width="90" height="90"/></a>
          <?php } else { ?>
          <a href="viewprofile.php?profid=<?php echo $query_rand_row['user_id'];?>"><img src="images/blank.jpg" border="0" width="90" height="90" /></a>
          <?php } ?>
        <?php } ?>
            <?php if($fetch_image['user_image']!='') {?>
              <img  src="images/user_images/<?php echo $fetch_image['user_image'];?>" border="0" />
              <?php } else { ?>
              <img  src="images/blank_big.jpg" height="90px;" width="90px;" />
              <?php } ?>
            <?php
                $lastlogin  = mysql_fetch_array(mysql_query("select * from user_lastlogin where user_id = '".$profid."' "));
                $onstatus   = $lastlogin['online_status'];
            ?>
            <?php if($onstatus=='1') { echo "Online"; } else { echo "Offline"; } ?>
                  <table width="400" border="0">
  <tbody>
    <tr>
      <td><label for="username">username:</label><?php echo $fetch_user['user_name'];?></td>
    </tr>
    <tr>
      <td><label for="username">location:</label><?php echo $fetch_info['city'];?></td>
    </tr>
    <tr>
      <td><label for="username">gender:</label><?php echo $fetch_user['user_gender'];?></td>
    </tr>
    <tr>
      <td><label for="username">age:</label><?php echo $fetch_user['age'];?></td>
    </tr>
    <tr>
      <td><label for="username">status:</label><?php echo $fetch_info['marital_status'];?></td>
    </tr>
    <tr>
      <td><label for="username">hair color:</label><?php echo $fetch_info['hair'];?></td>
    </tr>
    <tr>
      <td><label for="username">eye color:</label><?php echo $fetch_info['eyecolor'];?></td>
    </tr>
    <tr>
      <td><label for="username">height:</label><?php echo $fetch_info['height'];?>
                    cm ( <?php echo get_height($fetch_info['height'])?> )</td>
    </tr>
    <tr>
      <td><label for="username">best feature:</label><?php echo stripslashes($fetch_info['best_describes']);?></td>
    </tr>
    <tr>
      <td><label for="username">occupation:</label><?php echo stripslashes($fetch_info['your_profession']);?></td>
    </tr>
    <tr>
      <td><label for="username">drinks:</label><?php echo $fetch_info['drink'];?></td>
    </tr>
    <tr>
      <td><label for="username">drugs:</label><?php echo $fetch_info['drugs'];?></td>
    </tr>
    <tr>
      <td><label for="username">smoke:</label><?php echo $fetch_info['smoke'];?></td>
    </tr>
    <tr>
      <td><label for="username">education:</label><?php echo $fetch_info['education'];?></td>
    </tr>
    <tr>
      <td><label for="username">body type:</label><?php echo $fetch_info['bodytype'];?></td>
    </tr>
    <tr>
      <td><label for="username">religion:</label><?php echo $fetch_info['religion'];?></td>
    </tr>
    <tr>
      <td><label for="username">ethnicity:</label><?php echo $fetch_user['user_ethnicity'];?></td>
    </tr>
    <tr>
      <td><label for="username">Last Online:</label><?php echo ($lastlogin['lastlogin']);?></td>
    </tr>
    <tr>
      <td><label for="username">Member Since:</label><?php echo $fetch_user['reg_date'];?></td>
    </tr>
    <tr>
      <td><img src="images/arrow1.jpg" border="0" /></td>
    </tr>
    <tr>
      <td><img src="images/arrow2.jpg" border="0" /></td>
    </tr>
  </tbody>
</table>
        <?php 

        $sql_slide = mysql_query("select * from user_images where user_id = '".$fetch_user['user_id']."' and show_profile = '1' ");
        if(mysql_num_rows($sql_slide)>1) 
        {
        ?>
        <?php
            while($row_slide = mysql_fetch_array($sql_slide))
            {
            //print_r($row_slide);
        ?>
            <img src="images/user_images/smallthumb/<?php echo $row_slide['user_image'];?>" border="0" width="80" height="80" data-tooltip="sticky<?php echo $row_slide['id'];?>" />
        <?php 
            }
            ?>
            <?php
        }
        ?>
         <?php 
            $sql_slideh = mysql_query("select * from user_images where user_id = '".$fetch_user['user_id']."' and show_profile = '1'");
            while($row_slideh = mysql_fetch_array($sql_slideh))
            {
         ?>
                <?php echo $row_slideh['id'];?>" class="atip"> <img  src="images/user_images/<?php echo $row_slideh['user_image'];?>" />
                  <?php if($row_slideh['caption'] != '') { ?>
                    <?php echo $row_slideh['caption'];?>
                  <?php } ?>
                <?php 
            }
            ?>
      <form name="viewprofrm" id="viewprofrm" action="" method="post">
        <table>
        <tr>  
          <td><input type="hidden" name="favor_id" id="favor_id" value="<?php echo $profid; ?>" /><input type="image" src="images/add_favrt.jpg" name="button" id="button" value="favorite" onClick="return del_prompt(this.form,this.value)" height="68" /></td>
        </tr>  
        </table>
      </form>
      <a href="send_msg.php?uid=<?php echo $profid; ?>" class=""><input type="image" src="images/snd_mssg.jpg" name="button" id="button" value="Send message" height="68" /></a>
      <img src="images/box-bttm.png" />
</body>
</html>                  

This code is extremely difficult to read, the indentation is horrid, the question isn't quite clear to me (maybe I need sleep?)... what I can say is that you should sanitise your $_GET stuff. You seem to be putting it straight into the query which would allow me to do 1';DROP TABLE users;-- and drop your MySQL database table.

I truly admire your ability to write and read your codes in this form. However, I would also like to advice you to at least indent your codes, so that we can at least follow the flow of your script. PHP-FIG suggested PSR-1 and PSR-2.

Member Avatar for diafol

I realise that you came here for help with regard to a specific issue, but it seems that you're getting advice in how to sharpen your code without really addressing said issue. This isn't being obtuse, it's really really good advice. We can only help if we're able to see what's going on. We're all volunteers and have a limited amount of time, so if something looks like a lot of work to get straight, then you will probably find that contributors will simply skip your thread.

In addition to the remarks above. Try to separate out your PHP and markup as far as possible. The very least you should do is place the majority of it above the DTD.

As you've posted into PHP, perhaps you can cut away the CSS, needless markup and any irrelevant JS - it muddies the waters.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.