Utilizzare più form nella stessa pagina

Salve, ho questo codice , che sembra di non funzionare, ... come faccio ad gestire più due form, nella stessa pagina?

ecco il codice un pò casinato.

<?php
require_once(dirname(__FILE__) . '/../file/template_header.php');
if($_SESSION['logged_in'] == true | $_SESSION['User_Level'] == 1 | $_SESSION['User_Level'] == 2 | $_SESSION['User_Level'] == 3 )
{

$query = mysql_query ( "SELECT * FROM `users` WHERE `ID` = '" . mysql_codifica ( $_SESSION['user_id'] ) . "'" );
$r= mysql_fetch_assoc ( $query );


if(isset($_POST["update_EMAIL"]))
{
   $email = mysql_codifica($_POST['email']);
  $checkEmail = mysql_query("SELECT * FROM users WHERE Email = '".$email."'");
   
    if($email != $r['Email'])
   {if(mysql_num_rows($checkEmail) == 1)
     {
        $error =  "<h1>Error</h1>";
        $error =  "<p>Sorry, that checkEmail ".$email." is taken. Please go back and try again.</p>";
     }
     else
    {    
         $update = "UPDATE `users` SET `Email` = '" . mysql_codifica ( $email ) . "'";
            
         
            
            $update .= " WHERE `ID` = '" . mysql_codifica ( $_SESSION["user_id"] ) . "'";
            
            if ( mysql_query ( $update ) )
            {
                $msg = 'Aggiornato con sucesso!';
            }
            else {
                $error = 'ERROR: Please contact the administrator'.mysql_error();
            }            
            }            

     
   }
 
}

if(isset($_POST["update_PWD"]))
{
      $user = mysql_codifica((int)$_SESSION["user_id"]);
      $password = mysql_codifica($_POST["password"]);
   
         /* if we have a new password via POST we update the old one */
         if ( $_POST['password'] != '' )
         {
            $update = "UPDATE users SET `Password` = '" . md5 ( $password) . "' WHERE ID=$user";
             mysql_query ( $update );
              $msg = 'Your profile was successfully updated!';
         }else
{
}         
            
            }


   
// --------------fai l'aggiornamento-------------

$User_Level=$r["User_Level"];
$id = mysql_codifica((int)$_SESSION["user_id"]);
$query = "SELECT * FROM users WHERE ID = '".$id."'";
$result = mysql_query($query);
if(empty($id)) {
echo  "ID non specificato";
}
elseif (mysql_num_rows($result) == 0) { echo "Record non trovato"; }
else
{
?>
<p class="title2">Aggiornamento profilo di : <?php echo $_SESSION["username"] ?></p>
<table width="100%" border="1">
  <tr>
    <td align="center" valign="middle"><a href="update_profile.php">Profilo</a></td>
    <td align="center" valign="middle"><a href="update_firma.php">Firma</a></td>
    <td align="center" valign="middle"><a href="update_avatar.php">Avatar</a></td>
    <td align="center" valign="middle"><a href="update_account.php">Account</a></td>
  </tr>
</table>

<?php    if ( isset ( $error ) )    { echo '            <p class="error">' . $error . '</p>' . "\n";    }    ?>
<?php    if ( isset ( $msg ) )    { echo '            <p class="msg">' . $msg . '</p>' . "\n";    }    ?>


  <table width="100%" border="0">
     <tr>
          <td width="16%"><b>Username</b></td>
          <td width="84%"><p style="color:red;"><?php echo $r["Username"] ?></p></td>
    </tr>
    
  </table>
                    


 <form class="form" action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
    
        <input type="hidden" name="_submit_check" value="1"/>
    
        <table align="center" width="99%">
            
            <tr>
                <td><table width="100%" border="0" align="center">
                  <tr>
                    <td width="15%">Email</td>
                    <td width="85%"><input class="input" type="text" name="email" id="email" size="25" value="<?php if ( isset ( $_POST['email'] ) ) { echo $_POST['email']; } else { echo $r['Email']; } ?>" /></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td><input name="Update_EMAIL" type="submit"  class="submit-btn" id="Update_EMAIL" title="submit" value="Aggiorna" src="images/btn.gif" alt="submit" /></td>
                  </tr>
              </table></td>
            </tr>
            
        </table>
                    
    </form>
    
    
 <form class="form" action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
    
        <input type="hidden" name="_submit_check" value="1"/>
    
        <table align="center" width="99%">
            
            <tr>
                <td><table width="100%" border="0" align="center">
                  <tr>
                    <td width="15%">Password</td>
                    <td width="85%"><input class="input" type="text" name="password" id="password" size="25" value="<?php if ( isset ( $_POST['password'] ) ) { echo $_POST['password']; }  ?>" /></td>
                  </tr>
                  <tr>
                    <td>Nuova Password</td>
                    <td><input class="input" type="text" name="n_password" id="n_password" size="25" value="<?php if ( isset ( $_POST['n_password'] ) ) { echo $_POST['n_password']; } ?>" /></td>
                  </tr>
                  <tr>
                    <td>Conferma Password</td>
                    <td><input class="input" type="text" name="c_password" id="c_password" size="25" value="<?php if ( isset ( $_POST['c_password'] ) ) { echo $_POST['c_password']; }  ?>" /></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td><input name="Update_PWD" type="submit"  class="submit-btn" id="Update_PWD" title="submit" value="Aggiorna" src="images/btn.gif" alt="submit" /></td>
                  </tr>
              </table></td>
            </tr>
            
        </table>
                    
    </form>
  <?php
}
}
else
{
//the user is not an admin
   echo 'Sorry, you do not have sufficient rights to access this page.';
}
require_once(dirname(__FILE__) . '/../file/template_footer.php');
?>

cosa, ha che non va?

grazie, mille.

inviato 6 anni fa
luigi
X 0 X

niente, ho risolto.

era solo maiuscole/minuscole

if(isset($_POST["Update_EMAIL"]))

if(isset($_POST["Update_PWD"]))

grazie lo stesso.

risposto 6 anni fa
luigi
X 0 X
Effettua l'accesso o registrati per rispondere a questa domanda