cel'ho fatta a far comparire la domanda...creando una sequenza invece che su 2 pagine su 3;
"A" manda a "C" (il codice della domadna l'ho spostato in C) in modo che a mandi $ utente, $psw, $sesso a C e esegue la query e manda tutti i dati a B(pg interrogazione)
però la query di eliminazione continua a non andare
"A"
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
</head>
<body>
<?
session_start();
$link = mysql_connect('localhost', '', '')
or die('Could not connect: ' . mysql_error());
mysql_select_db('my_fabiovergotti') or die('Could not select database');
$utente = $_POST['utente'];
$sesso = $_POST['sesso'];
$pwd = $_POST['pwd'];
$query = "SELECT DOMANDA FROM generale WHERE ID='".$utente."' AND PASSWORD='".$pwd."' AND SESSO='".$sesso."'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$domanda=mysql_result($result,0,'DOMANDA');
$_SESSION['DOMANDA']=$domanda;
?>
<table width="100%" border="0">
<tr align="center" valign="middle">
<td align="left"><table width="100%" border="0">
<tr valign="middle">
<td width="50%" height="50%" align="right"><table width="69%" height="163" border="1" align="right">
<tr>
<td colspan="2">ACCOUNT DA ELIMINARE:</td>
</tr>
<tr>
<td>ID:</td>
</tr>
<tr>
<td>PASSWORD:</td>
</tr>
<tr>
<td>SESSO:</td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
<td width="50%" height="50%" align="left">
<form action="inserimento_dati2.php" method="post" name="inviadati" >
<table width="55%" border="1">
<tr>
<td> </td>
</tr>
<tr>
<td><input name="utente" type="text" class="celle_inserimento" id="textfield" style="text-transform:capitalize"/></td>
</tr>
<tr>
<td><input name="pwd" type="text" class="celle_inserimento" id="pwd" style="text-transform:capitalize"/></td>
</tr>
<tr>
<td><select name="sesso" class="celle_inserimento" id="SESSO" >
<option selected="selected"> </option>
<option value="m">Maschio</option>
<option value="f">Femmina</option>
<option value="anonimo">Anonimo</option>
</select></td>
</tr>
<tr>
<td><input type="submit" name="button" id="button" value="procedi" /></a></td>
</tr>
</table>
</form></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
"C"
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
</head>
<body>
<?
session_start();
$link = mysql_connect('localhost', '', '')
or die('Could not connect: ' . mysql_error());
mysql_select_db('my_fabiovergotti') or die('Could not select database');
$utente = $_POST['utente'];
$sesso = $_POST['sesso'];
$pwd = $_POST['pwd'];
$query = "SELECT DOMANDA FROM generale WHERE ID='".$utente."' AND PASSWORD='".$pwd."' AND SESSO='".$sesso."'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$domanda=mysql_result($result,0,'DOMANDA');
$_SESSION['DOMANDA']=$domanda;
?>
<table width="100%" border="0">
<tr align="center" valign="middle">
<td>
<form name="inviadati" method="post" action="interrogazione.php"><table width="50%" border="1">
<tr align="center" valign="middle">
<td colspan="2"><p>SEI SICURO DI VOLERTENE ANDARE??</p>
<p><img src="http://forum.it.altervista.org/../immagini_per_sito/smile_triste.png" width="91" height="90" /><br />
</p></td>
</tr>
<tr align="center" valign="middle">
<td width="50%" align="right">ID:</td>
<td width="50%" align="left"><input name="textfield" type="text" class="celle_inserimento" id="textfield2" style="text-transform:capitalize"/></td>
</tr>
<tr align="center" valign="middle">
<td align="right">PASSWORD:</td>
<td align="left"><input name="pwd2" type="text" class="celle_inserimento" id="pwd2" style="text-transform:capitalize"/></td>
</tr>
<tr align="center" valign="middle">
<td align="right">SESSO:</td>
<td align="left"><select name="sesso2" class="celle_inserimento" id="sesso" >
<option selected="selected"> </option>
<option value="m">Maschio</option>
<option value="f">Femmina</option>
<option value="anonimo">Anonimo</option>
</select></td>
</tr>
<tr align="center" valign="middle">
<td align="right"><? echo $domanda ?></td>
<td align="left"><input name="risposta2" type="text" class="celle_inserimento" id="risposta2" /></td>
</tr>
<tr align="center" valign="middle">
<td colspan="2"><input type="submit" name="button2" id="button2" value="PROCEDI CON L'ELIMINAZIONE" /></td>
</tr>
</table></form></td>
</tr>
</table>
<p> </p>
</body>
</html>
"B"
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
</head>
<body>
<?
session_start();
$link = mysql_connect('localhost', '', '')
or die('Could not connect: ' . mysql_error());
mysql_select_db('my_fabiovergotti') or die('Could not select database');
$utente = $_POST['utente'];
$sesso = $_POST['sesso'];
$pwd = $_POST['pwd'];
$domanda = $_SESSION['domanda'];
$risposta = $_POST['risposta'];
// AND DOMANDA='".$domanda."'
$query = " SELECT * FROM generale WHERE ID='".$utente."' AND SESSO='".$sesso."' AND PASSWORD='".$pwd."' AND DOMANDA='".$domanda."' AND RISPOSTA='".$risposta."'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$num_rows = mysql_num_rows($result);
//echo $num_rows;
//AND DOMANDA='".$domanda."'
if ($num_rows ==1){
$query_eliminazione = "DELETE FROM generale WHERE ID='".$utente."' AND SESSO='".$sesso."' AND PASSWORD='".$pwd."' AND DOMANDA='".$domanda."' AND RISPOSTA='".$risposta."'";
$result1 = mysql_query($query_eliminazione) or die('Query failed: ' . mysql_error());
}
?>
</body>
</html>