Allora quello dei posti era solo un esempio, ammetto di aver fatto un po' di confusione...
Io vorrei fare inserire dati di ad esempio un numero tramite dei form e inviare questi dati criptati in xml al database che controlla l'esistenza di questo numero e se esiste allora manda una risposta in ajax dicendo che esiste. Come faccio?
Ho provato a fare le modifiche che mi hai detto, apparte che cmq il codice che ho fatto io non fa quello che ti ho scritto sopra,come potrei modificarlo per far quello sopra?
Ho provato così,ma non funziona, non mi legge quello che è dentro il div info
provasito2.php
codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Post</title> </head> <body> <div id="xmldata"></div> <script type="text/javascript"> function readyAJAX() { try { return new XMLHttpRequest(); } catch(e) { try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) { try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) { return "Hai bisogno di un altro browser."; } } } } function mostraInfo(data) { var requestObj = readyAJAX(); var url = "mostra_utenti_prova.php"; var params = "q=" + data; requestObj.open("POST",url,true); requestObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); requestObj.send(params); requestObj.onreadystatechange = function() { if (requestObj.readyState == 4) { if (requestObj.status == 200) { var a=(requestObj.responseText); document.getElementById('info').innerHTML = a; } else { alert(requestObj.statusText); } } } } </script> <form> <form> Seleziona Dipendente: <select name="users" onChange="mostraInfo(this.value)"> <?php $db_host = "localhost"; $db_user = "administrator"; $db_password = "administrator"; $db_database = "ticket"; //Seleziono quelli che sono i dipendenti $connessione = mysql_connect($db_host,$db_user,$db_password); mysql_select_db($db_database, $connessione); $query = "SELECT * FROM user "; $result = mysql_query($query); while($riga = mysql_fetch_array($result)){ echo "<option value='$riga[user_id]'>$riga[user_firstname] $riga[user_lastname]</option>"; } ?> </select> </form> <div id="info"> var serverResponse = requestObj.responseXML; var header = serverResponse.getElementsByTagName("user"); htmlString = "<table><tr><th>Nome</th><th>Cognome</th><th>Username</th><th>Password</th><th>Email</th></tr>"; for (i=0; i<header.length; i++) { htmlString += "<tr>"; if (window.ActiveXObject) { htmlString += "<td>" + header[i].childNodes[0].text + "</td>"; htmlString += "<td>" + header[i].childNodes[1].text + "</td>"; htmlString += "<td>" + header[i].childNodes[2].text + "</td>"; htmlString += "<td>" + header[i].childNodes[3].text + "</td>"; htmlString += "<td>" + header[i].childNodes[4].text + "</td>"; } else { htmlString += "<td>" + header[i].childNodes[0].textContent + "</td>"; htmlString += "<td>" + header[i].childNodes[1].textContent + "</td>"; htmlString += "<td>" + header[i].childNodes[2].textContent + "</td>"; htmlString += "<td>" + header[i].childNodes[3].textContent + "</td>"; htmlString += "<td>" + header[i].childNodes[4].textContent + "</td>"; } htmlString += "</tr>"; } htmlString += "</table>"; document.getElementById('info').innerHTML = htmlString; </div> </body> </html>
mostra_utenti_prova.php
codice:<?php header('Content-Type: text/xml'); $db_host = "localhost"; $db_user = "administrator"; $db_password = "administrator"; $db_database = "ticket"; $q=$_POST['q']; $con = mysql_connect($db_host,$db_user,$db_password); mysql_select_db($db_database, $con); $sql="SELECT * FROM user WHERE user_id = '".$q."'"; $result = mysql_query($sql); $xml = new DomDocument('1.0'); $info = $xml->createElement('informations'); $info = $xml->appendChild($info); while ($row = mysql_fetch_array($result)) { $firstname = $xml->createElement('firstname'); $firstname = $info->appendChild($firstname); $value = $xml->createTextNode($row['user_firstname']); $value = $firstname->appendChild($value); $lastname = $xml->createElement('lastname'); $lastname = $info->appendChild($lastname); $value = $xml->createTextNode($row['user_lastname']); $value = $lastname->appendChild($value); $username = $xml->createElement('username'); $username = $info->appendChild($username); $value = $xml->createTextNode($row['user_username']); $value = $username->appendChild($value); $password = $xml->createElement('password'); $password = $info->appendChild($password); $value = $xml->createTextNode($row['user_password']); $value = $password->appendChild($value); $email = $xml->createElement('email'); $email = $info->appendChild($email); $value = $xml->createTextNode($row['user_email']); $value = $email->appendChild($value); } $output = $xml->saveXML(); echo "$output"; ?>


Rispondi quotando
