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>
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.046
150
63
PR
www.borgo-italia.it
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); ?
 

searedone

Utente Attivo
11 Giu 2010
508
0
0
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>
 

searedone

Utente Attivo
11 Giu 2010
508
0
0
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
Autore Titolo Forum Risposte Data
F Cerco Hosting con VECCHIE versioni di php Hosting 0
Cosina Captcha php PHP 1
S passare un valore da un form a un file .php con metodo post PHP 4
N php msyql PHP 6
N php problemi a visualizzare video PHP 3
A menu a tendina php PHP 1
D protezione cartelle: blocco visualizzazione/scaricamento contenuto, ma abilitazione utilizzo dati da parte di file .php presenti sul sito Web Server 1
F Php date_diff PHP 1
K [PHP] Aggiungere caratteri ad una stringa in base alla lunghezza della stessa PHP 2
C Wp-admin a file php WordPress 5
Lino80 [Retribuito] Cerco programmatore php per modifica/inserimento funzione/valori da un plugin importer wordpress Offerte e Richieste di Lavoro e/o Collaborazione 0
csi Inviare file jpg in locale alla stampante con php PHP 0
M Passaggio variabili array php su un tasto jq PHP 3
E Php aggiornamento tabella PHP 9
G phpmailer e php 8.1 con estensione mysqli PHP 6
M Invio dati database via email php PHP 0
K [php] Problema con inner join PHP 4
K [php]form invio dati PHP 0
P Codifica caratteri speciali mysql php PHP 0
K [PHP] Problema con variabili concatenate. PHP 1
E Stampante termica escpos-php PHP 6
JeiMax Modifica codice php personalizzato PHP 2
G Come modificare un pdf in php PHP 1
U Link a doppio file PHP PHP 0
E PHP & jQuery PHP 8
N Passare array da php a javascript PHP 5
F Applicazione PHP/MySQL per prenotazioni: limitare il numero massimo di posti prenotabili PHP 20
L tipo boolean non funzionante su mariadb (mysql). E codice php 7.4. PHP 0
U PHP creare un file excel dopo ricerca nel DB PHP 0
M PHP/MySQL - Estrarre valori min e max di ogni gruppo PHP 5
F Php e fatturazione elettronica PHP 0
P lanciare script asp (o php) da jquery Javascript 1
Couting95 inserire dati da un file di testo in una tabella in php PHP 1
P Data scraping in PHP non funziona PHP 4
C Calcoli matematici in php PHP 5
F Scrivere dei dati in word con php PHP 0
D PHP leggere cartella di Windows PHP 1
I dominio aruba versione php server linux Domini 3
G Colorare menu select attraverso ricerca php PHP 0
L PHP motore di ricerca nel sito PHP 1
S PHP e Mysqli PHP 0
Y Stampare da php su un foglio A6 attraverso una stampante esterna PHP 1
M Visulizzare immagine con php PHP 8
G [PHP] Creare script di prenotazione con controllo disponibilità. PHP 7
G leggere file txt e stampare con php il contenuto a video PHP 7
F Ricreare struttura php+mysql su Xampp Apache 0
Z PHP.INI - STMP per invio email con PHP Server Dedicati e VPS 0
M Array associativi php su 2 campi mysql PHP 10
G Invio form con PHP PHP 3
T fatture con voci fattura in php PHP 0

Discussioni simili