Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Submitted Numbers wont show.

    I started this tutorial that I found on my computer that I think I downloaded way back when... and there is a piece of code that doesnt seem to be working right. Its the commonly known, Order Form. Anyway, heres a few snippits of the code:

    PHP Code:
    <?
          
    echo "<p>Order processed at ";
          echo 
    date("H:i, jS F");
          echo 
    "<br>";
          echo 
    "<p>Your order is as follows:";
          echo 
    "<br>";
          echo 
    $tireqty." tires<br>";
          echo 
    $oilqty." bottles of oil<br>";
          echo 
    $sparkqty." spark plugs<br>"
    ?>
    What is happening, is when I go to show this on the actual page, it doesnt show the numbers that I placed into the previous HTML form.

    This is the HTML form:
    PHP Code:
    <form action="processorder.php" method="post">
    <
    table border="0">
    <
    tr bgcolor="#cccccc">
        <
    td width="150">Item</td>
        <
    td width="15">Quantity</td>
    </
    tr>
    <
    tr>
        <
    td>Tires</td>
        <
    td align="center"><input type="text" name="tireqty" size="3" maxlenght="3"></td>
    </
    tr>
    <
    tr>
        <
    td>Oil</td>
        <
    td align="center"><input type="text" name="oilqty" size="3" maxlength="3"></td>
    </
    tr>
    <
    tr>
        <
    td>Spark Plugs</td>
        <
    td align="center"><input type="text" name="sparkqty" size="3" maxlength="3"></td>
    </
    tr>
    <
    tr>
        <
    td colspan="2" align="center"><input type="submit" value="Submit Order"></td>
    </
    tr>

    </
    table>
    </
    form
    PHP is enabled on my computer, so thats not it. I think its a piece of that code. Any ideas? Thanks.

  • #2
    New Coder
    Join Date
    Apr 2004
    Location
    Texas
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    register_globals is turned off most likely

    Register_globals is turned off by default on newer releases of php, but was on by default in older releases of php. Some older samples still contain code that assumes register_globals is on.

    In short, to access these variables, you'll need to refer to them in the currently preferred method. Or, less advisable, enable register_globals in php.ini

    instead of
    echo $tireqty." tires<br>";
    try
    echo $_POST['tireqty']." tires<br>";
    Jason B

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This code that you showed me:

    echo $_POST['tireqty']." tires<br>";

    is exactly what I had changed it to before you answered. But I still had the problem. When I searched over my code, I noticed that I didnt have POST in all caps. So PHP didnt register it, and therefore, didnt pick up the numbers.

    Im glad you posted that, made things a lot clearer. Thanks

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To help you searching for errors like this one, which are due to typos, you can put

    PHP Code:
    error_reporting(E_ALL); 
    at the top of your script. The effect is that error notices pop up in your output if you try to access the content of a variable which isn't defined yet. That's a real timesaver.
    De gustibus non est disputandum.

  • #5
    New Coder
    Join Date
    Mar 2004
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah thanks for that!! Hopefully will be extremely helpful in times to come. Thanks again!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •