Codice PHP:
<html>
<head>
<title>Zomer - Richieste di maicizia, vedi chi vuole essere amicizio e scegli se stringere amicizia o ignorarlo!</title>
</head>
<body>
<div id="result"></div>
<div id="richieste">
<?php

error_reporting
(E_ALL);

require(
'../config.ini.php');

// Se non Ã¨ stata definita la variabile manda l'utente alla homepage
if(!isset($_SESSION['login']))
{
    
header('Location: ../login.php');
    exit;
}

//controllo se sono presenti richieste sul utente
  
echo "<div id=\"richieste\">";

               
//si conette al database e vede se ci sono richieste...

                
$query "SELECT * FROM richieste WHERE user='".$_SESSION['user']."'";
                
$select mysql_query($query) or die("Query fallita 
"
.mysql_error()."

"
.$query."");

                
$NumRow mysql_num_rows($select);

             
// Il recordset NON è vuoto
            
if ($NumRow>0){

//se ci sono richieste
    
while($row mysql_fetch_array($select))
     {

        echo
"<script>
var myRequest = null;

function CreateXmlHttpReq2(handler) {
  var xmlhttp = null;
  try {
    xmlhttp = new XMLHttpRequest();
  } catch(e) {
    try {
        xmlhttp = new ActiveXObject(\"Msxml2.XMLHTTP\");
    } catch(e) {
        xmlhttp = new ActiveXObject(\"Microsoft.XMLHTTP\");
    }
  }
  xmlhttp.onreadystatechange = handler;
  return xmlhttp;
}

function myHandler2() {
    if (myRequest.readyState == 4 && myRequest.status == 200) {
        e = document.getElementById(\"result\");
        e.innerHTML = myRequest.responseText;
    }
}

function accetta() {
    var nick = document.getElementById(\"nick\");
    var azione = accetta;
    var r = Math.random();
    myRequest = CreateXmlHttpReq2(myHandler2).value;
    myRequest.open(\"GET\",\"accetta.php?nick=\"+escape(nick)+\"&azione=\"+escape(azione)+\"&rand=\"+escape(r));
    myRequest.send(null);
}

function rifiuta() {
    var nick = document.getElementById(\"nick\");
    var r = Math.random();
    myRequest = CreateXmlHttpReq2(myHandler2);
    myRequest.open(\"GET\",\"accetta.php?nick=\"+escape(nick)+\"&rand=\"+escape(r));
    myRequest.send(null);
}

</script>"
;

        
//PENDO I DATI DELL'AMICO DALLA TABELLA UTENTI
        
$amico " SELECT * FROM utenti WHERE user = '".$row['mittente']."'";
        
$select2 mysql_query($amico) or die("Query fallita 
"
.mysql_error()."

"
.$amico."");
        
$dati mysql_fetch_array($select2);

 echo
"<div id=\"nick\" value=\"".$row['mittente']."\">L'utente  USURNAME: [b]".$row['mittente']."[/b] -  NOME:[b]".$dati['nome']."[/b]ti ha chiesto di essere suo amico  
 

 <img src=\"../immagini/icone/add_user.png\" border=\"0\" width=\"25\" hight=\"25\" onClick='javascript:accetta();'><a href=\"#\" onClick='javascript:accetta();'>Accetta</a>
 -
<img src=\"../immagini/icone/delete_user.png\" border=\"0\" width=\"25\" hight=\"25\" onClick='javascript:accetta();'><a href=\"#\" onClick='javascript:rifiuta();'\">Ignora</a></div>"
;
                          
                          
                        echo
" </div>";
     }
            }
?>


</body>
</html>