ciao ragazzi ho bisogno di un aiuto..sto creando una pagina di prova per la scuola dove devo inserire due valori che do io tramite un form dentro a un database in ajax..Il problema e che finche gli passo un parametro funziona tutto ma non so come fare per inserirne due e ho provato a scrivere cosi(non funziona mi inserisce solo valore):
HTML:
<html>
<body>
<script>
function createObject() {
var tipo_richiesta;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
tipo_richiesta = new ActiveXObject("Microsoft.XMLHTTP");
}else{
tipo_richiesta = new XMLHttpRequest();
}
return tipo_richiesta;
}
var http = createObject();
function inviadati(valore,prova) {
//image progress
http.open('get', 'inserisci.php?testo='+valore ||'prova='+prova);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if (http.readyState==3){
document.getElementById('dati').innerHTML ="[img]favicon.ico[/img]";
}
if(http.readyState == 4){
var response = http.responseText;
document.getElementById('dati').innerHTML = response;
}
}
</script>
<form name="theform">
<input type="text" name="word">
<input type="text" name="prova">
<input type="button" onClick="java-script:inviadati(document.theform.word.value, document.theform.prova.value );" value="inserisci">
</form>
<div id="dati"></div>
</body>
</html>
e qui il PHP:
<?
$user='root';
$password='';
$host='localhost';
$db="prova";
$testo=$_GET['testo'];
$prova=$_GET['prova'];
mysql_connect($host,$user,$password)or die("non riesco a connettermi");
mysql_select_db("$db")or die("non riesco selezionare il database");
$dati=mysql_query("insert into news(testo,prova) values('$testo','$prova')");
if($dati){echo"Dati salvati";}
else{echo"non inserito";}
?>
Dove sbaglio?