Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 11th, 2006, 05:02 AM
Registered User
 
Join Date: Jan 2006
Location: chicago, il, .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to iamdaniel
Default Ch5 : Form4.php pg 156-8 ... Not stepping

They seem to skip a step between 7 and 8 on page 157. They say to load form4.php and enter a movie name. The next step they say to add the film's year (but that's not even an option on this form.

When I hit "Add" or "Search" at the bottom of my form, it brings me to the same page with the Debug Dump, but not the AddMovie.php or AddPerson.php.

My code is correct. There are no parse errors. Can someone please help?

CODE:
form4.php
<?php
//debug info display
function debugDisplay(){
?>
<PRE>
$_POST
<?php
    print_r($_POST);
?>
$_GET
<?php
    print_r($_GET);
?>
</PRE>

<?php
}

//switch on search / add wizard step
switch( $_GET['step']){
    // search/add form
    case "1" :
        $type = explode(":",$_POST['type']);
        if ($_POST['Sumbit']=="Add"){
            require($_POST['Submit'].$type[0].'.php');
        } else {
            if( $_POST['type'] == "Movie:Movie" && $_POST['MovieType'] ==""){
                header("Location:form4.php");
            }
?>
<h1>Search Results</h1>
<p>You are looking for a "<?php echo $type[1]?>" named "<?php echo $_POST['Name']?>"</p>
<?php
    }
    if ($_POST['Debug'] == "on"){
        debugDisplay();
    }
    break;
    //Add Summary
    case "2":
        $type = explode(":",$_POST['type']);

?>
<h1>New <?php echo $type[1]?> : <?php echo $_POST['Name']?></h1>
<?php
    switch( $type[0] ) {
        case "Movie":
?>
<p>Released in <?php echo $_POST['MovieYear']?></p>
<p><?php echo n12br(stripslashes($_POST['Desc']))?></p>
<?php
        break;
    default:
?>
<h2>Quick Bio</h2>
<p><?php echo n12br(stripslashes($_POST['Bio']))?></p>
<?php
        break;
    }
    break;
    //starting form
    default;
        require('startform.php');
        break;
}
?>

=============================

startform.php
<html>
<head>
    <title>Multipurpose Form</title>
</head>
<body>
<form action="form4.php?step=1" method="post">
    <table border=0 width="750" cellspacing=1 cellpadding=1 bgcolor="#353535" align="center">
    <tr>
        <td bgcolor="#ffffff" width="30%">
            Name
        </td>
        <td bgcolor="#ffffff" width="70%">
            <INPUT type="TEXT" name="Name">
        </td>
    </tr>
    <tr>
        <td bgcolor="#ffffff">
            Item Type
        </td>
        <td bgcolor="#ffffff">
            <INPUT type="radio" name="type" value="Movie:Movie" checked>Movie<br>
            <INPUT type="radio" name="type" value="Person:Actor">Actor<br>
            <INPUT type="radio" name="type" value="Person:Director">Director<br>
        </td>
    </tr>
    <tr>
        <td bgcolor="#ffffff">
            Movie type (if applicable)
        </td>
        <td bgcolor="#ffffff">
            <select name="MovieType">
                <option value="" selected>movie type...</option>
                <option value="action">action</option>
                <option value="drama">drama</option>
                <option value="comedy">comedy</option>
                <option value="sci-fi">sci-fi</option>
                <option value="war">war</option>
                <option value="other">other...</option>
            </select>
        </td>
    </tr>
    <tr>
        <td bgcolor="#ffffff" width="50%">
            Display Debug Dump
        </td>
        <td bgcolor="#ffffff" width="50%">
            <input type="checkbox" name="Debug" checked>
        </td>
    </tr>
    <tr>
        <td bgcolor="#ffffff" colspan=2 align="center">
            <input type="submit" name="submit" value="Search">
            <input type="submit" name="submit" value="Add">
        </td>
    </tr>
    </table>
</form>
</body>
</html>

==========================================

addmovie.php

<?php
    if ($_POST['type'] == "Movie:Movie" && $_POST['MovieType'] == ""){
        header("Location:form4.php");
    }
    $title = $_POST['Sumbit']." ".$_POST['type']." : ".$_POST['Name'];
    $name= $_POST['Name'];
    $name[0] = strtoupper( $name[0]);
?>
<html>
<head>
    <title><?php echo $title?></title>
</head>
<body>
<form action="form4.php?step=2" method="post">
    <input type="hidden" name="type" value="<?php echo $type[1]?>">
    <input type="hidden" name="action" value="<?php echo $_POST['Submit']?>">
    <table border="1" width="750" cellspacing=1 cellpadding=3 align="center">
        <tr>
            <td width="30%">
                Movie Name
            </td>
            <td width="70%">
                <?php echo $name?>
                <input type="hidden" name="name" value="<?php echo $name?>">
            </td>
        </tr>
        <tr>
            <td>
                Movie Type
            </td>
            <td>
                <?php echo $_POST['MovieType']?><br />
                <input type="hidden" name="type" value="Movie: <?php echo $_POST['MovieTy[e']?>">
            </td>
        </tr>
        <tr>
            <td>
                Movie Year
            </td>
            <td>
                <select name="MovieYear">
                    <option value="" Selected>Select a year...</option>
                    <?php
                        for ($year=date("Y"); $year >=1970 ; $year--){
                    ?>
                    <option value="<?php echo $year?>"><?php echo $year?></option>
                    <?php } ?>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                Movie Description
            </td>
            <td>
                <textarea name="Desc" rows="5" cols="60"></textarea>
            </td>
        </tr>
        <tr>
            <td colspan=2 align="center">
                <input type="submit" name="submit" value="Add">
            </td>
        </tr>
    </table>
</form>
</body>
</html>

======================================
AddPerson.php


<?php
    $title = $_POST['Submit']." ".$_POST['type']." : ".$_POST['Name'];
    $name = $_POST['Name'];
    $name[0] = strtoupper( $name[0]);
?>
<html>
<head>
    <title><?php echo $title?></title>
</head>
<body>
<form action="form4.php?step=2" method="post">
    <input type="hidden" name="type" value="Person: <?php echo $type[1]?>">
    <input type="hidden" name="action" value="<?php echo $_POST['Submit']?>">
    <table border=1 width=750 cellspacing=1 cellpadding=3 align="center">
        <tr>
            <td width="30%">
                <?php echo $type[1]?> Name
            </td>
            <td>
                <?php echo $name?>
                <input type="hidden" name="Name" value="<?php echo $name?>">
            </td>
        </tr>
        <tr>
            <td>
                Quick Bio
            </td>
            <td>
                <textarea name="Bio" rows="5" cols="60"></textarea>
            </td>
        </tr>
        <tr>
            <td colspan=2 align="center">
                <input type="submit" name="submit" value="add">
            </td>
        </tr>
    </table>
</form>
</body>
</html>

========================
I'm assuming that in startform.php they have us send the form data to form4.php, which is why there is AddMovie or AddPerson in the sequence.

I'm constantly having to check the forums for solutions to every other problems.




Reply With Quote
  #2 (permalink)  
Old January 27th, 2006, 12:53 PM
Registered User
 
Join Date: Jan 2006
Location: penryn, cornwall, United Kingdom.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ah iamdaniel, I think I spotted it!

In your code for Form4.php there is a ; where the should be a :

It's on the 3rd (well 5th) line up from the bottom
default;

Code:
    default;
        require('startform.php');
        break;
}
?>
I hope that's it as I didn't read the rest - jumping to conclusions;)

The thing is I'm stuck on the same chapter, and it looks like everyone's new year resolution is to learn PHP from THIS book, when every chapter you have to do a lot of googling - the main reason I registered here!

My form4.php wont display anythin just a blank page...
Reply With Quote
  #3 (permalink)  
Old January 27th, 2006, 12:58 PM
Registered User
 
Join Date: Jan 2006
Location: penryn, cornwall, United Kingdom.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Spotted another thing:

addmovie.php

<?php
    if ($_POST['type'] == "Movie:Movie" && $_POST['MovieType'] == ""){
        header("Location:form4.php");
    }
    $title = $_POST['Sumbit']." ".$_POST['type']." : ".$_POST['Name'];
    $name= $_POST['Name'];
    $name[0] = strtoupper( $name[0]);
?>
<html>
<head>
    <title><?php echo $title?></title>
</head>
<body>
<form action="form4.php?step=2" method="post">
    <input type="hidden" name="type" value="<?php echo $type[1]?>">
    <input type="hidden" name="action" value="<?php echo $_POST['Submit']?>">
    <table border="1" width="750" cellspacing=1 cellpadding=3 align="center">
        <tr>
            <td width="30%">
                Movie Name
            </td>
            <td width="70%">
                <?php echo $name?>
                <input type="hidden" name="name" value="<?php echo $name?>">
            </td>
        </tr>
        <tr>
            <td>
                Movie Type
            </td>
            <td>
                <?php echo $_POST['MovieType']?><br />
                <input type="hidden" name="type" value="Movie: <?php echo $_POST['MovieTy[e']?>">

this last line - you missed the p key and hit [ instead
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 5 pg 156-7 error in book? ericfields6483 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 April 16th, 2009 04:18 PM
Ch 5 - form4.php loads itself blank Jotag BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 September 3rd, 2006 02:09 PM
Chapt 5 Help needed with Form4 example Getting_there_slowly BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 May 28th, 2005 10:42 AM
CH5 pg 150 While Loops wadesmart BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 11 November 8th, 2003 04:51 PM
stepping on .net raja .NET Web Services 1 July 14th, 2003 02:15 PM



All times are GMT -4. The time now is 07:07 PM.


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