salve ho questo script che mi prende le info dal form e me le manda a un altro file che me le elabora.
il problema e che sul database mi scrive undefinite.....nonostante il value è pieno
forse con i codici è piu' chiaro
index.php
invio.jsCodice PHP:<script type="text/javascript" src="../../../programmi/imagezoom/jquery-latest.js"></script>
<script type="text/javascript" src="invio.js"></script>
<form>
<fieldset>
<legend>Valutazione</legend>
Bellezza
1<input type="radio" name="bellezza" value="1" Change="valida();" />
2<input type="radio" name="bellezza" onChange="valida();" value="2"/>
3<input type="radio" name="bellezza" onChange="valida();" value="3"/>
4<input type="radio" name="bellezza" onChange="valida();" value="4"/>
5<input type="radio" name="bellezza" onChange="valida();" value="5"/>
6<input type="radio" name="bellezza" onChange="valida();" value="6"/>
7<input type="radio" name="bellezza" onChange="valida();" value="7"/>
8<input type="radio" name="bellezza" onChange="valida();" value="8"/>
9<input type="radio" name="bellezza" onChange="valida();" value="9"/>
10<input type="radio" name="bellezza" onChange="valida();" value="10"/>
<div id="message">
</div>
</fieldset>
</form>
invio.phpcodice:// JavaScript Document function valida() { var oXHR = new XMLHttpRequest(); oXHR.open("post","invio.php",true); oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); oXHR.onreadystatechange = function(){ if(oXHR.readyState == 4){ var message = document.getElementById("message"); if(oXHR.responseText =='OK'){ message.innerHTML = "<p style=\"color:red\">Email già usata</p>"; }else{ message.innerHTML =""; } } } var params ="bellezza=" + encodeURIComponent(document.forms[0].bellezza.value); oXHR.send(params); }
Codice PHP:<?php require_once('../../../Connections/connessione.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$trovato = false;
$insertSQL = sprintf("INSERT INTO prova (bellezza) VALUES ( %s)",
GetSQLValueString($_POST['bellezza'], "text"));
mysql_select_db($database_connessione, $connessione);
$Result1 = mysql_query($insertSQL, $connessione) or die(mysql_error());
$trovato = true;
if($trovato){
echo 'OK';
}else{
echo 'KO';
}
?>
a scrivere sul database scrive.....solo mi scrive undefinite

Rispondi quotando
