Salve, sto creando un sito dove è presente una form.
Quello che vorrei fare è che una volta compilati i dati, essa venga processata e ci sia uno script che verifichi la validità dei dati stessi, dando poi una risposta sotto forma di immagine positiva o negativa.
Per fare questo ho utilizzato php + ajax.
Vi posto il codice e vediamo insieme casomai perchè non funziona.
Premetto che ci sta la prima form registra.php che mantiene la struttura
Codice PHP:
<form method="post" >
<
table width="500" border="1">
  <
tr>
    <
td>Nick :</td>
    <
td><input id="usr" style="width: 150px; height: 16px;" type="text" value="" /></td>
    <
td><div id="div_usr" width="20"></div></td>
    <
td></td>
    <
td></td>
    <
td></td>
  </
tr>
  <
tr>
    <
td>Password :</td>
    <
td><input nome="pwd" type="password" id="pwd" style="width: 150px; height: 16px;" value=""></td>
    <
td><div id="div_pwd" width="20"></div></td>
    <
td>Ripeti Password :</td>
    <
td><input nome="pwd2" type="password" id="pwd2" style="width: 150px; height: 16px;" value=""></td>
    <
td><div id="div_pwd2" width="20"></div></td>
  </
tr>
  <
tr>
    <
td>Email</td>
    <
td><input id="mail" style="width: 150px; height: 16px;" type="text" value="" /></td>
    <
td><div id="div_mail" width="20"></div></td>
    <
td>Ripeti Email</td>
    <
td><input id="mail2" style="width: 150px; height: 16px;" type="text" value="" /></td>
    <
td><div id="div_mail2" width="20"></div></td>
  </
tr>
  <
tr>
    <
td></td>
    <
td></td>
    <
td></td>
    <
td></td>
    <
td></td>
    <
td><input type="button" value="Registra" 
onclick="registraform (
document.getElementById('usr').value,
document.getElementById('pwd').value,
document.getElementById('pwd2').value,
document.getElementById('mail').value,
document.getElementById('mail2').value
)" 
/></td>
  </
tr>
</
table>
</
form
il file xmlhttp.js che mantiene le funzioni javascript/ajax
Codice PHP:
    function registraform (thevalue1,thevalue2,thevalue3,thevalue4,thevalue5){
        
serverPage "registra2.php?sstring=" thevalue1 +":" thevalue2 +":" thevalue3+":" thevalue4+":" thevalue5;
        
objID "coda";

        var 
obj document.getElementById(objID);
        
xmlhttp.open("GET"serverPage);
        
xmlhttp.onreadystatechange = function() {
            if (
xmlhttp.readyState == && xmlhttp.status == 200) {
                
obj.innerHTML xmlhttp.responseText;
            }
        }
        
xmlhttp.send(null);
    }    

function 
makerequest(serverPageobjID) {
        
xmlhttp getxmlhttp ();
        var 
obj document.getElementById(objID);
        
xmlhttp.open("GET"serverPage);
        
xmlhttp.onreadystatechange = function() {
            if (
xmlhttp.readyState == && xmlhttp.status == 200) {
                
obj.innerHTML xmlhttp.responseText;
            }
        }
        
xmlhttp.send(null);
    } 
ed infine il file registra2.php che dovrebbe verificare se i dati sono scritti correttamente
Codice PHP:
require_once ("connessione.php");
    require_once (
"funzioni.php");
    
//And open a database connection.
    
$db opendatabase();
    echo 
$_GET['sstring'];
    list(
$usr,$pwd,$pwd2,$mail,$mail2) = explode(':',$_GET['sstring']);
    
//Setup the dynamic query string.

$controllo_usr false;
$controllo_pwd false;
$controllo_mail false;

$controllo_utente "SELECT * FROM mycurriculum_utenti WHERE usr= '$usr' ";
echo 
$controllo_utente;
$query mysql_num_rows(mysql_query($controllo_utente));


//    if ($check = mysql_query($controllo_utente))
    
if ($query == "0")
    {
        echo
"    <img src=\"http://forum.it.altervista.org/images/spaziatore.gif\" width=\"1\" height=\"1\" onload=\"makerequest('ok.php','div_usr')\">    ";

        
        
$controllo_usr true;
        }else 
        { 
// Il nick è già stato preso!
    //    $controllo_usr = false;
        
echo"    <img src=\"http://forum.it.altervista.org/images/spaziatore.gif\" width=\"1\" height=\"1\" onload=\"makerequest('no.php','div_usr')\">    ";

        }
        
        echo 
"
 usr :  
$controllo_usr  
"
;
        
    if (
strcmp($pwd,$pwd2) == "0" && !empty($pwd)) // se le password scritte sono uguali
            
{
                echo
"    <img src=\"http://forum.it.altervista.org/images/spaziatore.gif\" width=\"1\" height=\"1\" onload=\"makerequest('ok.php','div_pwd')\">    ";
                echo
"    <img src=\"http://forum.it.altervista.org/images/spaziatore.gif\" width=\"1\" height=\"1\" onload=\"makerequest('ok.php','div_pwd2')\">";
                
$controllo_pwd true;    
    
            }else     { 
// le password sono diverse
                        
$controllo_pwd false;
                        echo
"    <img src=\"http://forum.it.altervista.org/images/spaziatore.gif\" width=\"1\" height=\"1\" onload=\"makerequest('no.php','div_pwd')\">    ";
                        echo
"    <img src=\"http://forum.it.altervista.org/images/spaziatore.gif\" width=\"1\" height=\"1\" onload=\"makerequest('no.php','div_pwd2')\">";
                    }
        echo 
" pwd :  $controllo_pwd  
 "
;        
                    
    if(
strcmp($mail,$mail2) == "0" && ereg("@",$mail) && !empty($mail)) // le mail sono scritte uguali e sono effettivamtne email
        
{
            echo
"    <img src=\"http://forum.it.altervista.org/images/spaziatore.gif\" width=\"1\" height=\"1\" onload=\"makerequest('ok.php','div_mail')\">    ";
            echo
"    <img src=\"http://forum.it.altervista.org/images/spaziatore.gif\" width=\"1\" height=\"1\" onload=\"makerequest('ok.php','div_mail2')\">";
             
$controllo_mail true;
            
        }else { 
// Le mail non sono diverse
    //        $controllo_mail = false ;
            
echo"    <img src=\"http://forum.it.altervista.org/images/spaziatore.gif\" width=\"1\" height=\"1\" onload=\"makerequest('no.php','div_mail')\">    ";
            echo
"    <img src=\"http://forum.it.altervista.org/images/spaziatore.gif\" width=\"1\" height=\"1\" onload=\"makerequest('no.php','div_mail2')\">";
              }    
    
            echo 
" mail :  $controllo_mail 
 " 

In pratica faccio visualizzare due pagine php no e si contenenti giusto il link ad una immagine
no.php
Codice PHP:
[img]http://forum.it.altervista.org/images/no.gif[/img] 
solo che mi visualizza solo nel controllo delle mail, mentre non visualizza nulla sul controllo del nick e della password.

Spero di essere stato chiaro, e spero che qualcuno possa aiutarmi.