|
Subject:
|
moviesite login problem chapter 2
|
|
Posted By:
|
StuartD
|
Post Date:
|
8/7/2005 7:25:38 PM
|
hi there, I've got the same problem as the other guy: I can't login to the moviesite.php via login.php as per p61.
I followed the other thread, and inserted the code: while(list($key, $val) = each ($_POST)) { echo "$key -- > $val<br>"; }
in order to output the contents of POST and i get:
user -- > Joe pass -- > 12345 Submit -- > Submit
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/movie1.php:4) in /var/www/movie1.php on line 6 Sorry, but you don't have permission!
this is with the code inserted right fter the opening <?php tag, before the session_start()
can anyone help me out here? what does that output mean? My files are below. Thanks in advance for any replies. Stu
<?php while(list($key, $val) = each ($_POST)) { echo "$key -- > $val<br>"; } session_start(); $_SESSION['username']=$POST['user']; $_SESSION['userpass']=$POST['pass']; $_SESSION['authuser']=0;
//check username and password info
if (($_SESSION['username']== 'Joe') AND ($_SESSION['userpass']== '12345')) { $_SESSION['authuser']=1; } else { echo "Sorry, but you don't have permission!"; exit(); } ?> <html> <head> <title>Find my Favourite movie!</title> </head>
<body> <?php $myfavmovie=urlencode("Life of Brian"); echo "<a href='http://localhost/moviesite.php?favmovie=$myfavmovie'>"; echo "Click here to see information about my favourite movie!"; echo "</a>"; ?> </body> </html>
----------------------------
<?php session_start(); //check to see if user has logged in with a valid password if ($_SESSION['authuser']!=1) { echo "Sorry, no permissionz!"; exit(); } ?>
<html> <head> <title>My Movie Site - <?php echo $_REQUEST['favmovie'] ?></title> </head>
<body> <?php echo "Welcome to my site, "; echo $_SESSION['username']; echo "! <br>"; echo "My favourite movie is "; echo $_REQUEST['favmovie']; echo "<br>"; $movierate=5; echo "My rating for this movie is: "; echo $movierate; ?> </body> </html>
---------------------------------
<?php session_unset();
?> <html> <head> <title>Please Log In</title> </head>
<body> <form method="post" action="http://localhost/movie1.php"> <p>Enter you username: <input type="text" name="user"> </p> <p>Enter your password: <input type="password" name="pass"> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> </body> </html>
|
|
Reply By:
|
dbdave
|
Reply Date:
|
8/11/2005 5:45:28 PM
|
Ok, it seems that the form data is correctly being passed to the page. Remove the extra code and try it again.
Post back with any output received.
|
|
Reply By:
|
StuartD
|
Reply Date:
|
8/12/2005 6:47:49 PM
|
hi there, Ok did that, Im back to: 'Sorry, but you don't have permission!'
|
|
Reply By:
|
StuartD
|
Reply Date:
|
8/15/2005 6:04:37 AM
|
Ughhhh....
I have pored over this code again and again...I am either certain its the same as the code in the book, or am hallucinating. Can anyone see anything wrong with this? Or any deviations from the code on p59-60?
many thanks
|