Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

$_POST and $_REQUEST not initialized

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

$_POST and $_REQUEST not initialized

Postby nish1234 » Mon Dec 09, 2013 1:59 am

I am using php for the first time. I understand that creating a html form initializes such variables.

I have the following in my "AddItem.php" file:

Code: Select all
<?php require_once('../get-common/keys.php') ?>
<?php require_once('../get-common/eBaySession.php') ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>AddItem</TITLE>
</HEAD>
<BODY>
<FORM action="AddItem.php" method="post">
<TABLE cellpadding="2" border="0">
   <TR>
      <TD>listingType</TD>
      <TD>
          <select name="listingType">
            <option value="Chinese">Chinese</option>
            <option value="Dutch">Dutch</option>
            <option value="FixedPriceItem">Fixed Price Item</option>
            <option value="StoresFixedPrice">Stores Fixed Price</option>
          </select>
        </TD>
   </TR>
    <TR>
      <TD>primaryCategory</TD>
      <TD>
          <select name="primaryCategory">
       <option value="14111">test Category</option>
            <option value="57889">Boys Athletic Pants</option>
            <option value="57890">Boys Corduroys Pants</option>
            <option value="57891">Boys Jeans Pants</option>
            <option value="57892">Boys Khakis Pants</option>
          </select>
        </TD>
   </TR>
    <TR>
      <TD>itemTitle</TD>
      <TD><INPUT type="text" name="itemTitle" value="test IN SANDBOX BEFORE PROD - DO NOT BID" size=30></TD>
   </TR>
    <TR>
      <TD>itemDescription</TD>
      <TD><INPUT type="text" name="itemDescription" value="test IN SANDBOX BEFORE PROD - DO NOT BID - This will incur prod listing fees" size=30></TD>
   </TR>
    <TR>
     <TD>listingDuration</TD>
      <TD>
          <select name="listingDuration">
            <option value="Days_1">1 day</option>
            <option value="Days_3">3 days</option>
            <option value="Days_5">5 days</option>
            <option value="Days_7">7 days</option>
          </select>
          (defaults to GTC = 30 days for Store)
        </TD>
   </TR>
    <TR>
      <TD>startPrice</TD>
      <TD><INPUT type="text" name="startPrice" value="<?php echo rand(1,200) / 100 ?>"></TD>
   </TR>
    <TR>
      <TD>buyItNowPrice</TD>
      <TD><INPUT type="text" name="buyItNowPrice" value="<?php echo rand(299,599) / 100; ?>"> (set to 0.0 for Store)</TD>
   </TR>
    <TR>
      <TD>quantity</TD>
      <TD><INPUT type="text" name="quantity" value="1"> (must be 1 for Chinese)</TD>
   </TR>
   <TR>
      <TD colspan="2" align="right"><INPUT type="submit" name="submit" value="AddItem"></TD>
   </TR>
</TABLE>
</FORM>


<?php
   if(isset($_POST['listingType']))
        //....some more code
?>


On running the php file using
php -f AddItem.php
only the html for is printed on the console, the code inside the
<?php ?>
is not executed at all. I This is because $_POST is empty(prints "Array" on echo).
Could someone please point out my mistake here. Why is the $_POST variable not getting initialized?

Thanks
nish1234
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon Dec 09, 2013 1:51 am

Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.