this is the simplier example :
php page
<head>
<link rel="stylesheet" type="text/css" href="stile.css">
<script src="scripts.js" type="text/javascript">
</script>
</head>
<body>
<?php
$login=$_POST['identita'];
$q="select password,nome from utenti where login='$login'";
$host="localhost";
$connessione=mysql_connect($host,null,null);
mysql_select_db('magazzino');
$risultato=mysql_query($q);
$riga=mysql_fetch_array($risultato,MYSQL_BOTH);
$pw=$riga[0];
$nome=$riga[1];
$tipo=$riga[2];
if ($pw!=$_POST['password']) {
echo "<h2>Accesso non autorizzato a MAST</h2> ";
echo "<h4>Controllare la password immessa per identificare l'utente</h4>";
echo "<center><img src=img/logo.bmp width=300 height=100>";
echo "<br><a href=index.html>Torna all'accesso</a>";
exit();
}
mysql_free_result($risultato);
mysql_close($connessione);
?>
<p>Redirezione alla schermata iniziale in corso...</p>
<form method=POST name=formaccesso action=welcome.php>
<input type=hidden name=nome value="<?php echo $nome ; ?>">
<input type=hidden name=tipo value="<?php echo $tipo ; ?>">
</form>
<script type=text/javascript>
js_home();
</script>
</body>
and this is the javascript file
//SCRIPTS UTILIZZATI
function js_2190_variati (){
form1.submit();
return false;
}
function js_check(x){
if (x.checked==true) document.form1.ok.disabled=false;
return true;
}
function controlla_radio() {
var q=document.queryform.query.value.substring(0,6).toUpperCase();
if (q=='SELECT') {
document.queryform.costrutto[1].checked=false;
document.queryform.costrutto[0].checked=true;
}
}
function js_sql(){
if (document.queryform.costrutto[0].checked==true) {
var q=document.queryform.query.value.substring(0,6).toUpperCase();
if (q=='SELECT') {
document.queryform.action="select.php";
document.queryform.submit();
return;
}
else {
alert("La query di interrogazione deve iniziare con la clausola SELECT");
return;
}
}
else {
var input=prompt("Inserire password del DBA per l'aggiornamento del
database","");
if(input!="submit") alert("Operazione annullata");
else document.queryform.submit();
}
}
function js_cancella(){
if (confirm("I Dati cancellati non saranno più ripristinabili - Procedere
con la cancellazione?")==true) document.form1.submit();
else {
alert("Cancellazione annullata");
history.back();
return false;
}
return false;
}
function js_modifica(){
document.form1.submit();
return false;
}
function js_home(){
if (document.formaccesso)
document.formaccesso.submit();
else location.href="welcome.php";
}
function js_valore(nomecampo){
var campo='document.form1.'+nomecampo+'.value';
alert(campo);
return campo;
}
function select_all(n){
for (i=1;i<=n;i++)
eval("document.form1.cassa"+i+".checked=true");
document.form1.ok.disabled=false;
}
function deselect_all(n){
for (i=1;i<=n;i++)
eval("document.form1.cassa"+i+".checked=false");
document.form1.ok.disabled=true;
}
function js_reparti(){
var vera='update reparti ';
var sel='select * from reparti ';
var q="set Descrizione=\'";
q=q+document.reparti.descr.value+'\' ';
q=q+' where ID_Reparto='+document.reparti.rep.value;
sel=sel+' where ID_Reparto='+document.reparti.rep.value;
vera=vera+q;
alert(vera+'\n'+sel);
document.reparti.updatequery.value=vera;
document.reparti.selectquery.value=sel;
document.reparti.submit();
}
function js_config(){
document.form1.action="sqlcommand.php";
var vera="update azienda set ";
vera=vera+"Ragione_Sociale=\'"+document.form1.ragsoc.value+"\' , ";
vera=vera+"Indirizzo=\'"+document.form1.indirizzo.value+"\' , ";
vera=vera+"Cap=\'"+document.form1.cap.value+"\' , ";
vera=vera+"Citta=\'"+document.form1.citta.value+"\' , ";
vera=vera+"Provincia=\'"+document.form1.prov.value+"\' , ";
vera=vera+"CF=\'"+document.form1.cf.value+"\' , ";
vera=vera+"PIVA=\'"+document.form1.piva.value+"\' , ";
vera=vera+"Tel=\'"+document.form1.tel.value+"\' , ";
vera=vera+"Fax=\'"+document.form1.fax.value+"\' , ";
vera=vera+"Anno=\'"+document.form1.anno.value+"\' ";
vera=vera+"where ID_Azienda= '1'";
alert(vera);
document.form1.query.value=vera;
document.form1.tabella.value="Configurazione";
document.form1.submit();
}
function aggiorna_prezzo(){
var prezzoal=document.getElementById("prezzoal");
var contenuto=document.form1.misura.value;
vecchio=prezzoal.firstChild;
vecchio.data='Prezzo al '+contenuto+' : ';
}
function creaquery2(){
var q='update articoli set giacenza=';
q=q+js_valore('quantita');
q=q+', prezzo=';
q=q+js_valore('prezzo');
q=q+' where indice=';
q=q+js_valore('articolo');
document.form1.updatequery.value=q;
document.write(""+document.form1.updatequery.value);
}