Ho rivisto un pò il tutto... IL FILE JAVASCRIPT secondo voi così può cominciare ad andare bene???
Codice PHP:
<?php function leggi_cvs ($filepath) { $filepath= 'studenti.cvs'; $rowlength=6; $row= array(); if (($handle=fopen("$filepath", "r")) !== FALSE) while (($row=fgetcvs($handle)) !== FALSE) { for ($i=0; $i<$rowlength; $i++ {$rows[]= $row;} } fclose($handle);} return $rows;} function validate_cvs ($rows) { return prev_match ("/^[a-z0-9]{0,16}$/i", //stringhe da 0 a 16 caratteri alfanumeric "/^[a-z0-9]{0,16}$/i", "/^[a-z0-9]{0,16}$/i", "/^[a-z0-9]{0,16}$/i", "/\bBasic\b|\bNormal\b|\bFull\b/", //sole stringhe Basic, Normal, Full "/^(0[1-9]|[12][0-9]|3[01])[-](0[1-9]|1[012])[-](19|20)\d\d$/", //stringhe del tipo dd-mm-aaaa ) echo '{"results":'.json_encode($rows).'}'; php?>;}
//myjavas.js
function elabora (str)
{ var xhr= getXMLHttpRequest()
xhr.open( 'GET', 'mio.php?file='+str+', true);
xhr.onreadyStateChance==function()
{ if(xhr.readyState==4 && xhr.status==200)
{var risposta=xhr.responseText;}
}
xhr.send(null);}
function getXMLHttpRequest()
{...}
//file index.html
<HTML>
<HEAD>
<SCRIPT type="text/javascript" src="myjavas.js"> </SCRIPT>
</HEAD>
<BODY>
Richiedi dati </p>
<FORM> Inserisci :
<INPUT type="TEXT" onclick="elabora()"/>
</FORM>
</BODY>
</HTML>