myprofile.php ma mi prende l'id ma la pagina è quella dell'account loggato

searedone

Utente Attivo
11 Giu 2010
508
0
0
myprofile.php ma mi prende l'id ma la pagina è quella dell'account loggiato e non quella dell'account dell'id che mi prende l'struzione :

echo "<a href=\"myprofile.php?id=$user_id\">".$joke_ut['user_name']."</a><br />";

Vi posto il codice ...

PHP:
<?php 
include 'dbc.php';
page_protect();


?>
<html>
<head>
<title>My Account</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link href="styles.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr> 
    <td width="160" valign="top">
<?php 
/*********************** MYACCOUNT MENU ****************************
This code shows my account menu only to logged in users. 
Copy this code till END and place it in a new html or php where
you want to show myaccount options. This is only visible to logged in users
*******************************************************************/
if (isset($_SESSION['user_id'])) {?>
<div class="myaccount">
  <p><strong>My Account</strong></p>
  <a href="myaccount.php">My Account</a><br>
  <a href="mysettings.php">Settings</a><br>
    <a href="logout.php">Logout </a>
	
  <p>You can add more links here for users</p></div>
<?php }
if (checkAdmin()) {
/*******************************END**************************/
?>
      <p> <a href="admin.php">Admin CP </a></p>
	  <?php } ?>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p></td>
    <td width="732" valign="top"><p>&nbsp;</p>
      <h3 class="titlehdr">Welcome <?php echo $_SESSION['user_name'];?></h3>  
	  <?php	
      if (isset($_GET['msg'])) {
	  echo "<div class=\"error\">$_GET[msg]</div>";
	  }
	  	  
	  ?>
      <p>This is the my account page</p>
      

  
   <?php echo $_SESSION[''];?>

<br />
<br />
<br />
<?php

$id_u=$_SESSION['user_id'];  
$query = "SELECT * FROM annunci AS p WHERE p.user_id = '$id_u' OR p.user_id IN (SELECT user_1 FROM relationship AS r WHERE r.user_2 = '$id_u' AND r.amico = 'S') OR p.user_id IN (SELECT user_2 FROM relationship AS r WHERE r.user_1 = '$id_u' AND r.amico = 'S')";  
 
$ris=mysql_query($query);//*******!!!!!!!!!!!!*******non vedo questa istruzione 
   
while ($joke = mysql_fetch_array($ris)) {
$rich=$joke['user_id']; 
            $query_ut=mysql_query("SELECT * FROM users WHERE id=$rich");//non so come si chiama esattamente il campo id in user 
            //verifica e correggi eventualmente 
            $joke_ut=mysql_fetch_array($query_ut); 

$user_id = $joke['user_id'];    
$user_name = $joke['user_name'];
$commento = $joke['commento'];


 echo "<a href=\"myprofile.php?id=$user_id\">".$joke_ut['user_name']."</a><br />";
 
 
 echo "$commento<br /><br />"; 
 
 } 




?>


	 
 


      </td>
    <td width="196" valign="top">&nbsp;</td>
  </tr>
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
</table>

</body>
</html>
 
ciao
sei sicuro che debba essere

PHP:
//.....
$joke_ut=mysql_fetch_array($query_ut); 
$user_id = $joke['user_id'];    
$user_name = $joke['user_name'];
$commento = $joke['commento'];
echo "<a href=\"myprofile.php?id=$user_id\">".$joke_ut['user_name']."</a><br />";
//....
e non
PHP:
//.....
$joke_ut=mysql_fetch_array($query_ut); 
$user_id = $joke_ut['user_id'];    
$user_name = $joke_ut['user_name'];
$commento = $joke_ut['commento'];
echo "<a href=\"myprofile.php?id=$user_id\">".$joke_ut['user_name']."</a><br />";
//....

?
altrimenti a che ti serve
$joke_ut=mysql_fetch_array($query_ut); ?
 
Purtroppo siiii ne sono certo ..

ho provato in mille modi e se metto:

PHP:
$joke_ut=mysql_fetch_array($query_ut);  
$user_id = $joke_ut['user_id'];     
$user_name = $joke_ut['user_name']; 
$commento = $joke_ut['commento']; 
echo "<a href=\"myprofile.php?id=$user_id\">".$joke_ut['user_name']."</a><br />";

al posto di $joke non mi vengono fuori i commenti ...
la query :
$joke_ut=mysql_fetch_array($query_ut);

Lo utilizzata per avere lo user_name al posto dell'id visibile ...

il problema è che l'url mi restituisce http://localhost:8888/myprofile.php?id=61 prendendo l'id corretto dell0 user_name che clicco, ma nella pagina profile ho sempre e solo
la pagina dell'id che è loggato ..

posto anche il codice di myprofile non vorrei che l'errore è qui :(

PHP:
<?php 
include 'dbc.php';
page_protect();


?>
<html>
<head>
<title>My Account</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link href="styles.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr> 
    <td width="160" valign="top">
<?php 
/*********************** MYACCOUNT MENU ****************************
This code shows my account menu only to logged in users. 
Copy this code till END and place it in a new html or php where
you want to show myaccount options. This is only visible to logged in users
*******************************************************************/
if (isset($_SESSION['user_id'])) {?>
<div class="myaccount">
  <p><strong>My Account</strong></p>
  <a href="myaccount.php">My Account</a><br>
  <a href="mysettings.php">Settings</a><br>
    <a href="logout.php">Logout </a>
	
  <p>You can add more links here for users</p></div>
<?php }
if (checkAdmin()) {
/*******************************END**************************/
?>
      <p> <a href="admin.php">Admin CP </a></p>
	  <?php } ?>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p></td>
    <td width="732" valign="top"><p>&nbsp;</p>
      <h3 class="titlehdr">Welcome <?php echo $_SESSION['user_name'];?></h3>  
	  <?php	
      if (isset($_GET['msg'])) {
	  echo "<div class=\"error\">$_GET[msg]</div>";
	  }
	  	  
	  ?>
      <p>This is the my account page</p>
      
      <a href="accetta.php" />Controlla se hai richieste d'amicizia</a>
      
      <br />
      <br />
      
      <br />
<?php echo $_SESSION['user_id'];  
require ("db_connect.php"); 


if(isset($_POST['submit'])){//****verifico se è stato premuto il submit 
    $commento=$_POST["commento"];   
    $commento=ereg_replace("\n","<br>",$commento); //ereg_replace (come tutti gli ereg) è deprecato usa preg_replace   
    if(get_magic_quotes_gpc()) { 
        $commento=stripslashes($commento);    
    }    
    $commento =mysql_real_escape_string($commento);    
    $insert = mysql_query("INSERT INTO annunci SET  commento='$commento', user_id=".$_SESSION['user_id']."");    
}//fine if submit - penso che dovrebbe finire qui, comunque alla fine di tutte le azioni che sosno "azionate" dal form 
?>     
	 
 <div class="content">
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
     
      <p>
        <label for="commento"></label>
        <textarea name="commento" id="commento" cols="55" rows="20"></textarea>
      </p>
      <p>
        <input type="submit" name="submit" id="submit" value="Invia Commento" />
      </p>
    </form>
    </div>
    
    
   <?php 
   
   
require ("db_connect.php"); 



$result = mysql_query("SELECT * FROM annunci, users WHERE user_id=".$_SESSION['user_id']. " AND  user_id=users.id 
"); 


//recuperiamo i dati da stampare 


while ($records = mysql_fetch_array($result)) {  


$commento = $records['commento'];
$user_name = $records['user_name'];
$ts = $records['ts'];
 echo "<a href=\"myprofile.php?user_name=$user_name\">$user_name</a>"; 
echo "<h2> <img src='immagini/.gif' width='30' height='50' /> $user_name</h2> "; 
echo "<h6>$commento</h6> "; 
echo "<h6>$ts</h6> "; 



} 

?>


  
	 
	 
      </td>
    <td width="196" valign="top">&nbsp;</td>
  </tr>
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
</table>

</body>
</html>
 
non funziona :(

PHP:
<?php 
include 'dbc.php';
page_protect();


?>
<html>
<head>
<title>My Account</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link href="styles.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr> 
    <td width="160" valign="top">
<?php 
/*********************** MYACCOUNT MENU ****************************
This code shows my account menu only to logged in users. 
Copy this code till END and place it in a new html or php where
you want to show myaccount options. This is only visible to logged in users
*******************************************************************/
if (isset($_SESSION['user_id'])) {?>
<div class="myaccount">
  <p><strong>My Account</strong></p>
  <a href="myaccount.php">My Account</a><br>
  <a href="mysettings.php">Settings</a><br>
    <a href="logout.php">Logout </a>
	
  <p>You can add more links here for users</p></div>
<?php }
if (checkAdmin()) {
/*******************************END**************************/
?>
      <p> <a href="admin.php">Admin CP </a></p>
	  <?php } ?>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p></td>
    <td width="732" valign="top"><p>&nbsp;</p>
      <h3 class="titlehdr">Welcome <?php echo $_SESSION['user_name'];?></h3>  
	  <?php	
      if (isset($_GET['msg'])) {
	  echo "<div class=\"error\">$_GET[msg]</div>";
	  }
	  	  
	  ?>
      <p>This is the my account page</p>
      
      <a href="accetta.php" />Controlla se hai richieste d'amicizia</a>
      
      <br />
      <br />
      
      <br />
<?php echo $_SESSION['user_id'];  
require ("db_connect.php"); 


if(isset($_POST['submit'])){//****verifico se è stato premuto il submit 
    $commento=$_POST["commento"];   
    $commento=ereg_replace("\n","<br>",$commento); //ereg_replace (come tutti gli ereg) è deprecato usa preg_replace   
    if(get_magic_quotes_gpc()) { 
        $commento=stripslashes($commento);    
    }    
    $commento =mysql_real_escape_string($commento);    
    $insert = mysql_query("INSERT INTO annunci SET  commento='$commento', user_id=".$_SESSION['user_id']."");    
}//fine if submit - penso che dovrebbe finire qui, comunque alla fine di tutte le azioni che sosno "azionate" dal form 
?>     
	 
 <div class="content">
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
     
      <p>
        <label for="commento"></label>
        <textarea name="commento" id="commento" cols="55" rows="20"></textarea>
      </p>
      <p>
        <input type="submit" name="submit" id="submit" value="Invia Commento" />
      </p>
    </form>
    </div>
    
    
   <?php 
   
   
require ("db_connect.php"); 

$id=$_GET['id'];

$result = mysql_query("SELECT * FROM annunci, users WHERE id=$id"); 


//recuperiamo i dati da stampare 


while ($records = mysql_fetch_array($result)) {  

$id = $records['id'];
$commento = $records['commento'];
$user_name = $records['user_name'];
$ts = $records['ts'];
 echo "<a href=\"profile.php?user_name=$user_name\">$user_name</a>"; 
echo "<h2> <img src='immagini/.gif' width='30' height='50' /> $user_name</h2> "; 
echo "<h6>$commento</h6> "; 
echo "<h6>$ts</h6> "; 



} 

?>


  
	 
	 
      </td>
    <td width="196" valign="top">&nbsp;</td>
  </tr>
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
</table>

</body>
</html>
 

Discussioni simili