no non ci sono riuscito.....vi posto l'intero codice l'ho alleggerito al massimo .
l'errore è questo ,se metto la porzione di codice della stampa del msg di errore in cima(sotto session_start),mi stampa il msg.Mentre se lo metto alla fine della pagina non mi stampa niente.....perchè? sono le 4 e non riuscirò a dormire stanotte finchè non capirò l'errore
Codice PHP:
<?php
session_start
();

//stampa messaggio
 
if(isset($_SESSION['msg'])){
echo 
$_SESSION['msg'];
unset(
$_SESSION['msg']);
                    
               }
    
  
               
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_connessione "localhost";
$database_connessione "prova";
$username_connessione "root";
$password_connessione "";
$connessione mysql_pconnect($hostname_connessione$username_connessione$password_connessione) or trigger_error(mysql_error(),E_USER_ERROR); 
?>

<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}
?>
<?php
// *** Validate request to login to this site.

if(!isset($_SESSION['id'])){
    
$loginFormAction $_SERVER['PHP_SELF'];
if (isset(
$_GET['accesscheck'])) {
  
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset(
$_POST['mod_email'])) {
  
$loginUsername=$_POST['mod_email'];
  
$password=md5($_POST['mod_password']);
  
$MM_fldUserAuthorization "";
  
$MM_redirectLoginSuccess "prova.php";
  
$MM_redirectLoginFailed "prova.php?failed";
  
$MM_redirecttoReferrer true;
  
mysql_select_db($database_connessione$connessione);
  
  
$LoginRS__query=sprintf("SELECT email, password FROM utenti WHERE email=%s AND password=%s",
    
GetSQLValueString($loginUsername"text"), GetSQLValueString($password"text")); 
   
  
$LoginRS mysql_query($LoginRS__query$connessione) or die(mysql_error());
  
$loginFoundUser mysql_num_rows($LoginRS);
  if (
$loginFoundUser) {
     
$loginStrGroup "";
    
    if (
PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    
//declare two session variables and assign them
    
$_SESSION['MM_Username'] = $loginUsername;
    
$_SESSION['id'] = $loginUsername;
    
$_SESSION['MM_UserGroup'] = $loginStrGroup;    
    
$_SESSION['msg']="OK";      

    if (isset(
$_SESSION['PrevUrl']) && true) {
      
$MM_redirectLoginSuccess $_SESSION['PrevUrl'];    
    }
    
    
header("Location: " $MM_redirectLoginSuccess );
  }
  else {
      
$_SESSION['msg']="KO";
    
header("Location: "$MM_redirectLoginFailed );
  }
}
?>

<form action="<?php echo $loginFormAction?>" method="POST" name="login" id="form-login" >
                                                           <fieldset class="input">
                                                            <p id="form-login-email">
                                                             <label for="modlgn_email">Email</label>

                                                             <input id="modlgn_email" type="text" name="mod_email" class="inputbox" alt="email" size="18" />
                                                            </p>
                                                            <p id="form-login-password">
                                                             <label for="modlgn_password">Password</label>

                                                             <input id="modlgn_password" type="password" name="mod_password" class="inputbox" size="18" alt="password" />
                                                            </p>
                                                           
                                                              <span class="art-button-wrapper">
                                                                  <span class="art-button-l"> </span>
                                                                  <span class="art-button-r"> </span>
                                                                  <input type="submit" name="Submit" class="art-button" value="Login" />
                                                              </span>
                                                           </fieldset>
                                                          
                                                          </form>
                                          
                                                  <div class="cleared"></div>
                                              </div>
                                          </div>
                                  <div class="cleared"></div>
                              </div>
                          </div>
                          <?php
}else{


// ** Logout the current user. **
$logoutAction $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset(
$_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  
$logoutAction .="&"htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  
//to fully log out a visitor we need to clear the session varialbles
  
$_SESSION['MM_Username'] = NULL;
  
$_SESSION['MM_UserGroup'] = NULL;
  
$_SESSION['PrevUrl'] = NULL;
  
$_SESSION['id'] = NULL;
  unset(
$_SESSION['MM_Username']);
  unset(
$_SESSION['MM_UserGroup']);
  unset(
$_SESSION['PrevUrl']);
  unset(
$_SESSION['id']);
    
  
$logoutGoTo "prova.php";
  if (
$logoutGoTo) {
    
header("Location: $logoutGoTo");
    exit;
  }
}
?>
[url="<?php echo $logoutAction ?>"]Esegui logout[/url] 
<?php
}


/*/stampa msg
 if(isset($_SESSION['msg'])){
echo $_SESSION['msg'];
unset($_SESSION['msg']);
/*/
?>