sto cercando di fare un form di modifica informazioni
che preleva le info dal database , pero' mi stampa direttamente record aggiornato.....invece dovrebbe prima visualizzare il form con le info e poi tu modifichi e clicchi.....
cosa sbaglio??..
grazie ciao
codice:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
</head>
<body>
<?php
$host = 'localhost';
$user ='xxxxxxx';
$password = 'xxxxxxx';
$database = 'xxxxxxxx;
session_start();
$confirm=$_SESSION['userautorizzato'];
$email11 = $_SESSION['email2'];
$db= mysql_connect($host, $user, $password)
or die ("Impossibile connettersi al server $host");
mysql_select_db($database, $db)
or die ("Impossibile connettersi al database $db");
if(!$confirm)
{
$query = "SELECT * FROM users WHERE email= $email11";
$dbResult = mysql_query($query,$db);
$AffectedRows = mysql_affected_rows($db);
if ($AffectedRows==0)
{
echo " Non esistono record con i criteri selezionati ";
}else
{
mysql_data_seek($dbResult,0);
$row=mysql_fetch_row($dbResult);
print("<table>");
print ("<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">");
foreach ($row as $k => $v)
{
$myfield= mysql_fetch_field($dbResult,$k);
print("<tr><td>$myfield->name</td>");
print("<td><input type=\"text\" value=\"" . $v . "\" name =\"" . $myfield->name . "\" size=\"100\" maxlength = \"100\"></td></tr>");
}
print("<tr><td coolspam=\"2\"><input type = \"submit\" value=\"Conferma modifiche\"></td></tr> ");
print("<input type=\"hidden\" name =\"confirm\" value=\"1\">");
print ("</form>");
print("</table>");
mysql_free_result($dbResult);
mysql_close($db);
}
}
else{
$nome=$_REQUEST['nome'];
$cognome=$_REQUEST['cognome'];
$email=$_REQUEST['email'];
$sesso=$_REQUEST['sesso'];
$query= "UPDATE users SET nome=\"$nome\"," . " cognome=\"$cognome\"," . " email=\"$email\" , " ." sesso=\"$sesso\"" . "WHERE email = $email11";
$dbResult = mysql_query($query, $db);
$AffectedRows = mysql_affected_rows($db);
if($AffectedRows!=0)
{
print("Il record è stato aggiornato ");
}
mysql_close($db);
}
?>