Visualizzazione dei risultati da 1 a 3 su 3

Discussione: header php

  1. #1

    header php

    Salve a tutti,

    perché con questo script gli header non funzionano?
    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>LOGIN</title>
    </head>

    <body>



      <?php 
    include ("config.php"); 
    // mostro un eventuale messaggio
        
    if(isset($_GET['msg'])) {
            echo 
    '[b]'.htmlentities($_GET['msg']).'[/b]

    '
    ;
        }


    if (isset(
    $_POST['invia'])) {

        
    $username $_POST['user'];
        
    $password $_POST['pwd'];
        
        
    $username trim(mysql_real_escape_string($username));
        
    $password trim(mysql_real_escape_string($password));
        
        if(
    get_magic_quotes_gpc()) {
            
    $nome      stripslashes($nome);
            
    $password  stripslashes($password);
        }
        
        
        if (!
    $username || !$password) {
        
        echo 
    "dovete inserire dei dati";
         }else{
         
        
    $query "SELECT id_user FROM users_sito WHERE username ='$username' AND password='$password'";
        
    $result mysql_query ($query,$db) or die (mysql_error()); 
        
    $righe mysql_num_rows($result);
        
        if (
    $righe 0) {
        
    $messaggio urlencode("autentificazione effettuata");
        
    header("location: $_SERVER[PHP_SELF]?msg=$messaggio");
            exit; 
        
        }else{
            
    $messaggio urlencode("autentificazione non effettuata");
        
    header("location: $_SERVER[PHP_SELF]?msg=$messaggio");
            exit; 
        
    }
    }

    }



    ?>
    </p>


    LOGIN </p>
    <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
      <label>user
      <input type="text" name="user" id="user" />
      </label>
      <label>password
      <input type="text" name="pwd" id="pwd" />
      </label>
      <label>
      <input type="submit" name="invia" id="invia" value="Invia" />
      </label>
    </form>



    </body>
    </html>
    Questione di spazi?

  2. #2
    Ci si potrebbe fare un intero forum solo con questa domanda

    Il problema - come detto un milione di volte - e' che prima di un header() non ci deve essere nessun output.

  3. #3
    Codice PHP:
     <?php 
    include ("config.php"); 
    // mostro un eventuale messaggio
        
    if(isset($_GET['msg'])) {
            echo 
    '[b]'.htmlentities($_GET['msg']).'[/b]

    '
    ;
        }


    if (isset(
    $_POST['invia'])) {

        
    $username $_POST['user'];
        
    $password $_POST['pwd'];
        
        
    $username trim(mysql_real_escape_string($username));
        
    $password trim(mysql_real_escape_string($password));
        
        if(
    get_magic_quotes_gpc()) {
            
    $nome      stripslashes($nome);
            
    $password  stripslashes($password);
        }
        
        
        if (!
    $username || !$password) {
        
        echo 
    "dovete inserire dei dati";
         }else{
         
        
    $query "SELECT id_user FROM users_sito WHERE username ='$username' AND password='$password'";
        
    $result mysql_query ($query,$db) or die (mysql_error()); 
        
    $righe mysql_num_rows($result);
        
        if (
    $righe 0) {
        
    $messaggio urlencode("autentificazione effettuata");
        
    header("location: $_SERVER[PHP_SELF]?msg=$messaggio");
            exit; 
        
        }else{
            
    $messaggio urlencode("autentificazione non effettuata");
        
    header("location: $_SERVER[PHP_SELF]?msg=$messaggio");
            exit; 
        
    }
    }

    }



    ?>
    così funziona alla meraviglia

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.