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 Creating Paypal Buttons

Charles Franklin
Charles Franklin
17,535 Points

Error Detected - PayPal

I'm having trouble with adding items to the shopping cart on PayPal. It worked a few days ago but now when I add an item, it gives me the folllowing:

Some required information is missing or incomplete. Please correct your entries and try again.

So I've gone back and dbl checked my product ID's. They are correct. I've redone the code for the submit items and they are correct. I cant quite figure out why I'm getting this error message.

As a side note I'm in PHP Stage 5 and I've gone ahead and created a paypal account. but some of the screen shots that Randy has shown dont exactly match what is currently on PayPal. I can figure that out easily enough but I didnt know if that added to the discussion.

My gut tells me its something to do with target="paypal" or the method="post"

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

$product_id = $_GET["id"]; $product = $products[$product_id];

$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>
            <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_id" value="<?php $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">
                                            <option value="Small">Small </option>
                                            <option value="Medium">Medium </option>
                                            <option value="Large">Large </option>
                                        </select>
                                    </td>
                                </tr>   
                            </table>        
                        <input type="submit" value="Add to Cart" name="submit">
                    </form>
                <a class="shirt-designer">*All Shirts are designed by Mike the Frog</a>  
            </div>
        </div>
    </div>

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

1 Answer

on the line that says the following:

<input type="hidden" name="hosted_button_id" value="<?php $product["paypal"]; ?>"> 

you want top add an echo statement, as follows

  <input type="hidden" name="hosted_button_id" value="<?php echo $product["paypal"]; ?>">