Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    autenticazione in locale va in remoto no

    ecco il codice:
    Codice PHP:
    //setto un array con nomi utenti e pwd




      
    if (!isset($_SERVER['PHP_AUTH_USER'])) {
       
    header('WWW-Authenticate: Basic realm="Zona protetta"');
       
    header('HTTP/1.0 401 Unauthorized');
       die(
    "Autenticazione necessaria!");
       } 
       
       else {
              if (((
    $_SERVER['PHP_AUTH_USER']=="Carlo") && ($_SERVER['PHP_AUTH_PW'] == $users[Carlo]))
                or ((
    $_SERVER['PHP_AUTH_USER']=="Giulia") && ($_SERVER['PHP_AUTH_PW'] == $users[Giulia]))
                or ((
    $_SERVER['PHP_AUTH_USER']=="Matteo") && ($_SERVER['PHP_AUTH_PW'] == $users[Matteo]))
                or ((
    $_SERVER['PHP_AUTH_USER']=="Luca") && ($_SERVER['PHP_AUTH_PW'] == $users[Luca]))
                or ((
    $_SERVER['PHP_AUTH_USER']=="Umberto") && ($_SERVER['PHP_AUTH_PW'] == $users[Umberto]))
                or ((
    $_SERVER['PHP_AUTH_USER']=="Guest") && ($_SERVER['PHP_AUTH_PW'] == $users[Guest])))
                
                {
    $auth="yes";}
            
            else 
    $auth="no";
            
            if(
    $auth=="no"){
                
    $u=$_SERVER['PHP_AUTH_USER'];
                
    header('WWW-Authenticate: Basic realm="Zona protetta"');
                
    header('HTTP/1.0 401 Unauthorized');
                echo 
    'Utente';
                print(
    $u);
                echo
    ' non riconosciuto!
    '
    ;
                echo 
    '<a href=\"mailto:webmaster@fotoboni.com\">Contatta il webmaster per ottenere l\'accesso.</a>';
                exit;}
        } 

    dove sbaglio????

    In remoto chiede utente e pwd e non fa mai accedere
    in locale con utente giusto mi fa accedere.
    problemi di compatibilità di qualcosa?
    (in locale ho php 5.0.3 in remoto ho 4.4.1)

  2. #2
    Questo é il mio script di login vedi se ti puo servire:

    Pagina login.php:
    Codice PHP:
    <?php require_once('connection/config.inc.php');?>
    <?php 

    // Avvio la Sessione

    session_start();

    // Verivico se submit e definito

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

    // Definisco le variabili $Username, $Password, $LoginOk

    $Username $_POST['usr'];
    $Password $_POST['pwd'];
    $LoginOk "admin.php";

    // Query per verificare il login su database

    $query "SELECT * FROM tb_user WHERE usr_username='$Username' AND usr_password=md5('$Password')";
    $result mysql_query($query);
    if(
    mysql_num_rows($result) > 0) {

    // Metto in sessione il nome utente e la password
     
    $_SESSION['UserName'] = $Username;
     
    $_SESSION['Password'] = $Password;

    // Reindirizzo alla pagina admin.php se il login é corretto
     
    header("Location: $LoginOk");

    // Chiudo lo script in caso che la condizione sia vera
     
     
    exit();

    }
    else

    // Messaggio di errore in caso di login errato
     
    $msg "<span class=\"errorLoginRed\">Password o nome utente errati!\n</span>";
    }

    ?>
    <head>
    <link href="css/style.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    <table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><form name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
          <table width="300" border="0" cellpadding="0" cellspacing="0" bordercolor="#990000">
            <tr>
              <td height="30" colspan="2"><div align="center" class="testo">Area Login: </div></td>
            </tr>
            <tr>
             <td height="30" colspan="2"><div align="center"><?php echo $msg ;?>
             </div></td>
            </tr>
            <tr>
              <td width="150" height="30"><div align="center" class="testo">Username :</div></td>
              <td width="150" height="30">
                <div align="left">
                  <input name="usr" type="text" class="boxins" id="usr">
                  </div></td>
            </tr>
            <tr>
              <td height="30"><div align="center" class="testo">Password :</div></td>
              <td height="30">
                <div align="left">
                  <input name="pwd" type="password" class="boxins" id="pwd">
                  </div></td>
            </tr>
            <tr>
              <td height="30"></td>
              <td height="30">
                <div align="left">
                  <input name="Submit" type="submit" class="boxins" value="Login">
                  </div></td>
            </tr>
          </table>
            </form>
        </td>
      </tr>
    </table>


    </body>
    </html>
    Pagina protetta per es admin.php:

    Codice PHP:
    <?php
    // Avvio la sessione

    session_start();

    // Controllo che il nome utente e la password in sessione siano corretti, altrimenti torna alla pagina di login

    if ($_SESSION['UserName']=="" && ($_SESSION['Password']=="")) {
        
    header("Location: login.php");
    }


    ?>
    Ciao Michel
    PHP THE BEST

  3. #3

    lo script ce l'ho e funziona

    ma funzia solo in locale...
    e non so perchè

  4. #4

  5. #5
    Prova a dare all'utente che vuoi che si colleghi da fuori i privilegi sul db:

    grant privilegi on nomeDB.[tabelle] to utente (senza @localhost) identified by 'pass'


  6. #6

    Il problema è

    che non uso un db. ma semplicemente un array.
    e in locale va.

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.