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!!!