Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Simple PHP Application Integrating with PayPal Adding Available Sizes

Maybe not setup local server correctly

Hello ! I am having problems with this php course, I understand it perfectly but for exemple when I try to build the dynamic sizes for the tshirts i do exactly as randy does but it displays an empty shirt page :

<?php
include("inc/products.php");

if (isset($_GET["id"])) {

    $product_id = $_GET["id"];
    if (isset($products[$product_id])) {
        $product = $products[$product_id];
    }
}

if (!isset($product)) {
    header("Location: shirts.php");
    exit();
}


$section = "shirts";
$pageTitle = $product["name"];
include("inc/header.php");?>

        <div class="section page">

            <div class="wrapper">

                <div class="breadcrumb"><a href="shirts.php">Shirts</a> &gt; <?php echo $product["name"] ?>

                <div class="shirt-picture">
                    <span>
                        <img src="<?php echo $product["img"] ?>" alt"<?php echo $product["name"]; ?>">
                    </span>
                </div>

                <div class="shirt-details">
                    <h1><span class="price">$<?php echo $product["price"]?></span> <?php echo $product["name"]?></h1>

                    <form target="paypal" action="https://www.paypal.com.cgi-bin/webscr" method="post">
                    <input type="hidden" name="cmd" value="s-xclick">
                    <input type="hidden" name="hosted_button" value="<?php echo $product["paypal"]?>">
                    <input type="hidden" name="item_name" value="<?php echo $product["name"]?>">    
                    <table>
                        <tr>
                            <th>
                                <input type="hidden" name="on0" value="Size">
                                <label for="os0">Size</label>
                            </th>
                            <td>
                                <select name="os0" id="os0">
                                    <?php foreach ($product["sizes"] as $size) {?>
                                    <option value="<?php echo $size; ?>"><?php echo $size; ?></option>

                                    <?php  } ?>
                                </select>
                            </td>
                        </tr>
                    </table>
                    <input  type="submit" value="Add to Cart" name="submit">
                    </form>
                    <p class="note-designer">* All shirts are designed by Mike the Frog.</p>
                </div>
                </div>

            </div>

        </div>

<?php include("inc/footer.php"); ?>     

Also, the contact page submits and redirects to the contact page as expected but without the status=thanks so when I submit it, there is another blanc page :

<?php

if ($_SERVER["REQUEST_METHOD"] == "POST") {

    $name = $_POST["name"];
    $email = $_POST["email"];
    $message = $_POST["message"];
    $email_body = "";

    $email_body = $email_body . "Name: " . $name . "\n"; 
    $email_body = $email_body . "Email: " . $email . "\n";
    $email_body = $email_body . "Message: " . $message;

    // TODO: Send Email

    header("Location: contact.php?status=thanks");
    exit;
}

?>


<?php 
$pageTitle = "Contact Mike";
$section = "contact";
include("inc/header.php"); ?>

    <div class="section page">


        <div class="wrapper">

        <?php if (isset($_GET["status"]) AND $_GET["status"] == "thanks") { ?>
            <p>Thanks for the email! I&rsquo;ll be in touch shortly.</p>
        <?php } else { ?>

                <h1>Contact</h1>

                <p>I&rsquo;d love to hear from you! Complete the form to send me an email.</p>

                <form method="POST" action="contact.php">

                    <table>
                        <tr>
                            <th>
                                <label for="name">Name</label>
                            </th>
                            <td>
                                <input type="text" name="name" id="name">
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label for="email">Email</label>
                            </th>
                            <td>
                                <input type="text" name="email" id="email">
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label for="message">Message</label>
                            </th>
                            <td>
                                <textarea name="message" id="message"></textarea> 
                            </td>
                        </tr>

                    </table>
                    <input type="submit" value="Send">

                </form>

            <?php } ?>  
        </div>


    </div>
<?php include("inc/footer.php"); ?>

Maybe I have not setup the local server correctly ? Please help it is difficult to follow the course with no shirt page and a contact page that does not submit :(

I got the shirts page to work correctly but the contact still does not work