Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 9th, 2006, 03:09 AM
Registered User
 
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 2 Pg. 75-77 while function

Hello

When I login to view the moviesite.php file, no matter what amount I choose to list; It just says

"My top movies are" (then its blank)

I think it may have something to do with on page 77, where it states "//list the movies"

I have not listed them.

I've tried... but i'm not sure as to if i'm actually supposed to or not. AND I wouldn't know whether to list them with ";" or quote marks or brackets etc etc.

The following is the code for the 3 files it uses..... please help im stuck!!

--------------

<?php
session_unset();

?>
<html>
<head>
<title>Please Log In</title>
</head>

<body>
<?php include "header.php"; ?>
<form method="post" action="movie1.php">
<p>Enter Your Username:
<input type="text" name="user" />
</p>
<p>Enter Your Password:
<input type"password" name="pass" />
</p>
<p>
<input type="submit" name="submit" value="Log In">
</p>
</form>
</body>
</html>

---------------

<?php
session_start();
$_SESSION['username'] = $_POST['user'];
$_SESSION['userpass'] = $_POST['pass'];
$_SESSION['authuser'] = 0;

//check user and password infomation
if (($_SESSION['username'] == 'Joe') and
($_SESSION['userpass'] == '12345')) {
$_SESSION['authuser'] = 1;
} else {
echo "Sorry, but you don't have permission to view this page, YOU Loser!";
exit();
}
?>
<html>
<head>
<title>Find my favourite 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 info about my favourite movie!";
echo "</a>";
echo "<br>";
echo "Or choose how many you would like to see:";
echo "</a>";
echo "<br>";
?>
<form method="post" action="moviesite.php">
<p>Enter number of movies (up to 10):
<input type="text" name"num">
<br>
Check here if you want them sorted alphabetically
<input type="checkbox" name"sorted">
</p>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

-----------

<?php
session_start();

//check to see if the user has logged in with a valid password
if ($_SESSION['authuser'] != 1) {
echo "Sorry, but you don't have permission to view this page, you loser!";
exit();
}
?>
<html>
<head>
<title>My Movie Site</title>
</head>
<body>
<?php include "header.php"; ?>
<?php
$favmovies = array("Life of brian",
                    "stripes",
                    "office space",
                    "the holy grail",
                    "matrix",
                    "Term 2",
                    "star wars",
                    "close encounters of the third kind",
                    "16 candles",
                    "caddyshack");


if (isset($_REQUEST['favmovie'])) {
echo "Welcome to our site ";
echo $_SESSION['username'];
echo "! <br>";
echo "My Favourite movie is ";
echo $_REQUEST['favmovie'];
echo "<br>";
$movierate = 5;
echo "My movie rating for this movie is: ";
echo $movierate;
} else {
echo "My top ". $_POST["num"] . " movies are:<br>";

    if (isset($_REQUEST['sorted'])) {
    sort($favmovies);
    }
//list the movies
$numlist = 1;
while ($numlist <= $_POST["num"]) {
    echo $numlist;
    echo ". ";
    echo pos($favmovies);
    next($favmovies);
    echo "<br>\n";
    $numlist = $numlist + 1;
}
}
?>
</body>
</html>


$pleasework
 
Old November 30th, 2006, 03:43 PM
Authorized User
 
Join Date: Jul 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello there. Please post the error message that your getting - (it will make it a little easier)- i got threw that chapter- so i'm sure i will be able to help you.

 
Old February 28th, 2007, 04:27 PM
Authorized User
 
Join Date: Feb 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I hope u've figured this out by now but if not then here's ur error:--
         /*use this*/ <input type="text" name="num">
  /*instead of this*/ <input type="text" name"num"
  in ur movie1.php file; by currently using the second line u r not able to pass on the variable 'num' to ur movie1.php file so none of the selected movies r being displayed.
......cheers......






Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 3 pg 95 al2000 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 August 4th, 2008 09:18 PM
save images in size .75 X .75 infotech VB How-To 2 May 11th, 2007 05:54 PM
chapter 5, pg 154 spizotfl BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 3 May 1st, 2007 03:08 PM
Chapter 4 pg 131 cpkaiser BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 May 2nd, 2004 01:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.