Salve a tutti,
ho fatto una pagina di profilo dove si esegue una ricerca di un utente, ma mi da l'errore di sintassi: 'Notice: Undefined variable: username in /membri/asdf/result_search2.php on line 35', perché se specifico che la variabile $username è quella presa dal form di ricerca?

Ecco il codice della pagina del profilo:
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>KnowEveryone</title>
</head>
<body style="background-color:#036">
<div id="barra" style="height: 8%; position: fixed; top: 0px; bottom: 0; left: 0; width: 100%; background-color: #006699; border-bottom: 1px solid #133783; position:fixed !important">
<p style="margin-top:1%; margin-bottom:1%; margin-left:1%; color:#FFF; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; font-size:150%; font-weight:bold; text-align:left">KnowEveryone [url="profile2.php"]<?php session_start(); print "({$_SESSION['utente']})";?>[/url][url="login2.php?azione=logout"] Esci[/url]</p>
</div>
<?php
include 'header.php'
session_start();
error_reporting(E_ALL);
print 
"<p class='saluto'>{$_SESSION['utente']}</p>";
print 
"[url='prechat.html']Chat comune[/url]";
?>
<div class="sidebar2">
<iframe name="visualizza" width="100%" height="80%" frameborder="1" src="bacheca_visualizza.php" style="background-color:white; border:1px solid white" scrolling="yes"></iframe>
<center><iframe name="visualizza" width="100%" height="10%" frameborder="1" src="bacheca_input.php" style="background-color:white; border:1px solid #CCCCCC; background-color:#0165B6" scrolling="no"></iframe></center>
</div>
<div class="sidebar1">
<center>
<?php
error_reporting
(E_ALL);
$dati mysql_query("SELECT foto FROM utenti WHERE username='".$_SESSION['utente']."'");
$risultatomysql_fetch_array($dati);
$_SESSION['foto'] = $risultato['foto'];
echo 
'[img]'.$risultato['foto'].'[/img]';
?>
<iframe name="visualizza" width="65%" height="20%" frameborder="1" src="infopersonali.php" style="margin-top:10%; background-color:white; border:1px solid black"></iframe>
<p style="margin-top:5%">[url="modifica_dati2.php"][modifica dati][/url]</p>
<iframe name="visualizza" width="65%" max-height="25%" frameborder="1" src="statoprofilo.php" style="background-color:white; border:1px solid black"></iframe>
<?php 


            
if(!isset($_POST['post'])){ ?>
            
                <form method="post" action="#" id="modificastato" style="alignment-adjust:central">
                    
                    <ul>
                        <label for="post" style="font-size:120%; color:white; margin-left:-11%; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif">Inserisci il tuo stato:</label>
                        

                            <input type="text" name="post" id="post" style="width:65%; height:120%; font-size:120%; border:1px solid black; margin-left:-12%; margin-top:5%" />
[/list]
                        <input type="submit" name="invia" id="salva" value="Salva" style="width:20%; height:9%; color:black; background-color:white; border:1px solid black; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; font-size:110%; margin-bottom:5%" />
                </form>        
    <?php    } else {
                                
                
// Valori del form
                
                
$post mysql_real_escape_string($_POST['post']);
                
                        
// Invia dati alla tb utenti
                        
                        
$query="UPDATE utenti SET post='".$post."' WHERE  username='".$_SESSION['utente']."'"
$inviautente=mysql_query($query) or die(mysql_error());
header("Refresh: 1; URL= profile2.php?id={$_SESSION['utente']}#");
                        
                        
                        }
    
?>
<?php
            
if(!isset($_POST['cerca'])){ ?>
            
                <form method="post" action="#" id="formricerca" style="alignment-adjust:central">
                    
                    <input type="text" name="username" id="username" style="margin-bottom:5%; width:65%; height:9%; font-size:120%; border:1px solid black"; placeholder="Cerca una persona qui"/>
                    <input type="submit" name="cerca" id="cerca" value="Cerca" style="width:20%; height:9%; color:black; background-color:white; border:1px solid black; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; font-size:110%; margin-bottom:5%"/>
                </form>        
    <?php    } else {
                                
                        
$username mysql_real_escape_string($_POST['username']);
                        if(
$username == ""){
                    
                        echo 
"Attenzione, devi compilare tutti i campi";
                    
                        } else {
                        
                        
$recuperadati mysql_query("SELECT * FROM utenti WHERE username= '$username'");
                                 
                                
$verificadati mysql_num_rows($recuperadati); 
                                 
                                if(
$verificadati == 1){ 
                                 
                                    echo 
"[url='result_search2.php?id=$username']$username[/url]";
                                    
                                    } else { 
                                 
                                    echo 
"<p class='noresult'>Nessun risultato trovato! Aggiorna la pagina per eseguire una nuova ricerca.</p>"
                                    } 
                             
                            } 
                         
                        } 
                     
?>

</div>
</body> 
</html>
Ecco, invece, quello della pagina result_search2.php:

[php]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>KnowEveryone</title>
</head>
<body style="background-color:#036">
<div id="barra" style="height: 8%; position: fixed; top: 0px; bottom: 0; left: 0; width: 100%; background-color: #006699; border-bottom: 1px solid #133783; position:fixed !important">
<p style="margin-top:1%; margin-bottom:1%; margin-left:1%; color:#FFF; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; font-size:150%; font-weight:bold; text-align:left">KnowEveryone <?php session_start(); print "({$_SESSION['utente']})";?> Esci</p>
</div>
<?php
include 'header.php';
session_start();
error_reporting(E_ALL);
print "<p class='saluto'>$username</p>";
?>
<div class="sidebar2">
<iframe name="visualizza" width="100%" height="80%" frameborder="1" src="bacheca_visualizza2.php" style="background-color:white; border:1px solid white" scrolling="yes"></iframe>
</div>
<div class="sidebar1">
<center>
<?php
error_reporting(E_ALL);
$dati = mysql_query("SELECT foto FROM utenti WHERE username='$username'");
$risultato= mysql_fetch_array($dati);
echo '[img]'.$risultato['foto'].'[/img]';
?>
<iframe name="visualizza" width="65%" height="20%" frameborder="1" src="infopersonali.php" style="margin-top:10%; background-color:white; border:1px solid black"></iframe>
<p style="margin-top:5%">[modifica dati]</p>
<iframe name="visualizza" width="65%" max-height="25%" frameborder="1" src="statoprofilo.php" style="background-color:white; border:1px solid black"></iframe>
</div>
</body>
</html>

Grazie a tutti in anticipo per il vostro aiuto.
Saluti,
cicciaramba.