Visualizzazione dei risultati da 1 a 5 su 5

Discussione: Superniubbo HELPP!!

  1. #1
    Utente bannato
    Registrato dal
    Nov 2011
    Messaggi
    150

    Superniubbo HELPP!!

    Sto faticosamente cercando di capire qualcosa di PHP, prendendo esempio da un libro ma...

    login.php

    codice:
    <?php
    session_unset();
    ?>
    <html>
     <head>
      <title>Please Log In</title>
     </head>
     <body>
    <?php include 'header.php'; ?>
      <form method="post" action="movie1.php">
       
    
    Enter your username: 
        <input type="text" name="user"/>
       </p>
       
    
    Enter your password: 
        <input type="password" name="pass"/>
       </p>
       
    
    
        <input type="submit" name="submit" value="Submit"/>
       </p>
      </form>
     </body>
    </html>
    movie1.php
    codice:
    <?php
    session_start();
    $_SESSION['username'] = $_POST['user'];
    $_SESSION['userpass'] = $_POST['pass'];
    $_SESSION['authuser'] = 0;
    
    //Check username and password information
    if (($_SESSION['username'] == 'Joe') and
        ($_SESSION['userpass'] == '12345')) {
        $_SESSION['authuser'] = 1;
    } else {
        echo 'Sorry, but you don\'t have permission to view this page!';
        exit();     
    }
    ?>
    <html>
     <head>
      <title>Find my Favorite Movie!</title>
     </head>
     <body>
    <?php include 'header.php'; ?>
    <?php
    $myfavmovie = urlencode('Life of Brian');
    echo "<a href=\"moviesite.php?favmovie=$myfavmovie\">";
    echo "Click here to see information about my favorite movie!";
    echo "</a>";
    ?>
      
    
    
      
    
      Or choose how many movies you would like to see:
      
    
      <form method="post" action="moviesite.php">
       
    
    Enter number of movies (up to 10): 
        <input type="text" name="num" maxlength="2" size="2"/>
        
    
        Check to sort them alphabetically: 
        <input type="checkbox" name="sorted" />
       </p>     
       <input type="submit" name="submit" value="Submit"/>
      </form>
     </body>
    </html>
    Mi saltano fuori errori quando provo dalla pagina login.php a "lanciare" la movie1.php

    L'errore è questo
    Notice: Undefined index: user in C:\nginx\html\script\movie1.php on line 3

    Notice: Undefined index: pass in C:\nginx\html\script\movie1.php on line 4
    Sorry, but you don't have permission to view this page!

    che in pratica dovrebbe voler dire che manca il controllo "isset" sui parametri, ma i parametri... non arrivano a movie1.php

    Come mai? HELLLPPPPP!!!

  2. #2
    Utente di HTML.it L'avatar di danlupo
    Registrato dal
    Jul 2009
    Messaggi
    314
    Ho provato il tuo codice, ma quando tu immetti Joe lo fai tutto minuscolo o con la prima lettera maiuscola; perchè sono diversi se non mi ricordo male..

    Cioè Joe è diverso da joe

  3. #3
    Utente bannato
    Registrato dal
    Nov 2011
    Messaggi
    150
    Scrivo Joe.
    Ma da quanto posso "intuire" il problema non è che non viene riconosciuto il dato, è che proprio non arriva al secondo script (movie1.php).

    Preciso che uso nginx e php "accrocchiati" su Windows (non so se era meglio apache)

  4. #4
    Utente di HTML.it L'avatar di danlupo
    Registrato dal
    Jul 2009
    Messaggi
    314
    Non conosco nginx perchè ho sempre usato il tridente Apache MySql PHP, ti ho chiesto come lo scrivessi perchè io ho fatto copia incolla del tuo codice e mi ha funzionato con Joe portandomi alla pagina richiesta.

  5. #5
    Il titolo della discussione non rispetta il regolamento del forum

    http://forum.html.it/forum/showthrea...readid=1470525
    Addio Aldo, amico mio... [03/12/70 - 16/08/03]

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 © 2024 vBulletin Solutions, Inc. All rights reserved.