Jump to content

Archived

This topic is now archived and is closed to further replies.

kenwvs

Explain how this if (isset ($_POST['Submit'])) works

Recommended Posts

I am hoping someone can explain how this isset command works. I think this is what is stopping my validaton from working, but I don't understand it. I got it from the validation tutorial on a site, and copied it, then made some modifications.


[code]
<?php
/* sample.php */

require_once ('functions.php');

$valid = TRUE;

if (isset ($_POST['Submit'])) {
foreach($_POST as $key=>$value) {
$$key = $value;
}

$valid = $user = LettersAndDigits($id);
$title = Variable($item_title);
$valid = $valid && $title;
$category = ItemCategory($item_category);
$valid = $valid && $category;
$type = Variable($item_type);
$valid = $valid && $type;
$quantity = isDigits($quantity_available);
$valid = $valid && $quantity;
$price = Dollars($starting_bid);
$valid = $valid && $price;
$increment = BidIncrement($bid_increment);
$valid = $valid && $increment;
$reserve = ReservePrice($reserve_price);
$valid = $valid && $reserve;
$length = isDigits($duration);
$valid = $valid && $length;
$time = isDigits($end_time);
$valid =$valid && $time;
$relist = isLetters($auto_relist);
$valid = $valid && $relist;
$ct = Variable($city);
$valid = $valid && $ct;
$prov = Variable($state);
$valid = $valid && $prov;
$cntry = Variable($country);
$valid = $valid && $cntry;
$desc = Variable($item_description);
$valid = $valid && $desc;
$pay = EmailorEmpty($paypal_id);
$valid = $valid && $pay;
$hit = Variable($hit_counter);
$valid = $valid && $hit;
if ($valid) {
// header ("uploadformconfirmation.html");
exit;
}
} else {
$user = $title = $category = $type = $quantity = $price = $increment =
$reserve = $length =$time = $relist = $ct = $prov = $cntry = $desc = $pay =
$hit = TRUE;
$id = $item_title = $item_category = $item_type = $quantity_available =
$starting_bid = $bid_increment = $reserve_price = $duration = $end_time =
$auto_relist = $city = $state = $country = $item_description = $paypal_id =
$hit_counter = '';
}
?>
[/code]

Share this post


Link to post
Share on other sites
Ummm, did you try the manual:  http://www.php.net/isset

[quote]
isset -- Determine whether a variable is set

Description
bool isset ( mixed var [, mixed var [, ...]] )

Returns TRUE if var exists; FALSE otherwise.
[/quote]

Share this post


Link to post
Share on other sites
You bet I sure did, but I am having trouble understanding what they are really trying to say and how it relates in the way I have used it.

Ken

Share this post


Link to post
Share on other sites
Your code is checking to see if the variable $_POST['submit'] has been set...if it exists.  If it does exist, then it loops through the $_POST array and creates variables (the easy way of doing the same thing is to use extract (http://www.php.net/extract)).

If you want to see what the $_POST array contains, do a print_r (http://www.php.net/print_r) on it.  If you want to see a formatted display, put a pre tag (html's &ltpre&gt) before it.  If you see a key with the name "submit", then the isset operation should return true and the loop will happen.

Are you sure that is where your error is?  I'm not familiar with how the rest of your code is executing with a lot of $var = $var = func($var) and so on...there is a lot of custom functions being executed and a lot of logic that has the potential to go wrong.  If you are experiancing problems, you may want to simplify as much as possible.

Share this post


Link to post
Share on other sites
It basically says that if there is a field in your form that is named "Submit" and it is set when this statement is executed, then do the rest of the code in the statement block.

Most forms have a Submit button. For this to work that field must be named "Submit" and your form needs to be sent by the method="post".

Here is how the submit but should look for this to work:
[code]<input type="submit" name="Submit" value="Send Information">[/code]
The words in the value attribute are what appears in the submit button on the screen and also get sent to the processing script.

If you are unsure of what is being passed back to your script, put this line at the start of your script and take a look at what is displayed:
[code]<?php echo '<pre>' . print_r($_POST,true) . '</pre>'; ?>[/code]

Ken

Share this post


Link to post
Share on other sites
When I put the print_r in my script and run it I simply get      array
                                                                                    (
                                                                                      )

I am assuming this isn't good and something isn't quite right.

When you say to see what is displayed, I put it in my PHP expert Editor and then hit run and this is what I see.  I do know that there is a submit button, and it is set up properly. 

Ken

Share this post


Link to post
Share on other sites
What is the method that your form is using?

Please post the code that generates the form.

Ken

Share this post


Link to post
Share on other sites
I am thinking this is what you wanted to see, atleast I hope so.

<tr>
    <td>
        <p><b><font face="Arial" size="2">
        Please verify all details shown for your item
        before pressing the SAVE button.</font></b>
    </td>
    <td><input type="submit" name="Submit" value="SAVE  ITEM">
    </td> <font size="2">
</tr>

Share this post


Link to post
Share on other sites
No, I want to see the "<form>" tag.

Ken

Share this post


Link to post
Share on other sites
Here is the code for the form itself.  When I reread the question, it made more sense what you were after.  Sorry

Ken

[code]<body bgcolor="#F5F3F5">
<p align="center"><b><font face="Arial" size="3" color="#0000FF">Quick Lister</font></b></p>
<p align="center"><b><font face="Arial" color="#FF0000">For Sale 4 U - Canada's
Online Auction</font></b></p>
<p align="center"><font face="Arial" size="2"><b>Please note:&nbsp; </b>You may
not use characters such as $, #, &quot;, &amp;, *,/, etc.&nbsp; It is best to use normal
text and numerical characters only.&nbsp;
<?php
if (!$valid) {
?>
<style type="text/css">
td.error {color:C03; font-weight:bold; }
</style>
Please correct the items in red and resubmit.<br /><br />
<?php
}
?>
<form method="POST" action="sample.php">
<HR>
<?php echo '<pre>' . print_r($_POST,true) . '</pre>'; ?>
<tr>
   <td> <font size="2"<?php if(!$user) echo 'class="error"'; ?>> User ID:
   </td></font>
   <td> <font size="2">&nbsp;<font face="Arial"><input type="text" name="id"
        size="12" value="<?= $id ?>"
   </td></font>
   <td> &nbsp;&nbsp;<font size="2">You must use the <B>same User ID</B>
        for all items you are uploading during this session.</font>
        <font size="2">(It does not have to be your regular username.)
   </td><BR><P> </font>
</tr>
<tr>
   <td><font face="Arial"><font size="2"<?php if(!$title) echo
        'class="error"'; ?>>  Item Title:
   </td></font>
   <td><font size="2">&nbsp;<input type="text" name="item_title"
        size="60" value="<?= $item_title ?>"
   </td></font>
   <td> <font size="2"<?php if(!$category) echo 'class="error"'; ?>>&nbsp;
        Item Category:
   </td></font>
   <td> <select size="1" name="item_category" value="<?= $item_category ?>">
        <option value="000">Please Select Category</option>
        <option value="150">Antiques</option>
        <option value="18">Automobiles - Cars</option>
        <option value="75">Home and Garden - Lawnmowers</option>
        <option value="76">Home and Garden - Rototillers</option>
        <option value="77">Home and Garden - Gardening Tools and small equipment
        </option>
        <option value="78">Home and Garden - Services</option>
        <option value="79">Home and Garden - Sheds</option>
        <option value="92">Home Electronics - Gaming Machines</option>
        <option value="87">Computers and Accessories - Monitors</option>
        <option value="88">Computers and Accessories - Printers</option>
        <option value="89">Computers and Accessories - CPU's</option>
        <option value="90">Computers and Accessories - Complete Systems</option>
        <option value="91">Computers and Accessories - Accessories</option>
        <option value="103">Computers and Accessories - Services</option>
        <option value="98">Televisions - Flat Screen</option>
        <option value="99">Televisions - Under 20"</option>
        <option value="100">20 inch and over</option>
        <option value="101">Televisions - Plasma</option>
        <option value="84">Cameras - Digital Camera</option>
        <option value="85">Cameras - Camcorders</option>
        <option value="86">Cameras - Others</option>
        <option value="93">Stereos - Speakers</option>
        <option value="94">Stereos - Components</option>
        <option value="95">Stereos - All in One</option>
        <option value="96">Home Electronics - DVD and VCR</option>
        <option value="97">Home Electronics - MP3, Discman, etc.</option>
        <option value="105">Construction - Services</option>
        <option value="106">Construction - Equipment</option>
        <option value="107">Construction - Tools</option>
        <option value="109">Construction - Products - New</option>
        <option value="110">Construction - Products - Used</option>
        <option value="118">Employment Ads - Retail</option>
        <option value="119">Employment Ads - Restaurant</option>
        <option value="120">Employment Ads - General Labourer</option>
        <option value="121">Pets</option>
        <option value="122">Services - Professional</option>
        <option value="123">Services - Tradesman</option>
        <option value="124">Services - Child Care</option>
        <option value="126">Services - Yard Care and Snow Removal</option>
        <option value="127">Services - Moving and Storage</option>
        <option value="128">WANT ADS</option>
        <option value="134">Automotive Stereos and Radar Detectors</option>
        <option value="135">Home Electronics - Telephone</option>
        <option value="136">Home Electronics</option>
        <option value="137">Personal Care Products</option>
        <option value="138">Toys</option>
        <option value="113">Arts and Crafts</option>
        <option value="130">Jewellery and Watches - Watches</option>
        <option value="131">Jewellery and Watches - Rings</option>
        <option value="132">Jewellery and Watches - Beaded Jewellery</option>
        <option value="133">Jewellery and Watches - Engagement and Wedding</option>
        <option value="102">Televisions - Projection</option>
        <option value="19">Automobiles - Trucks</option>
        <option value="20">Automobiles - Antique Vehicles</option>
        <option value="21">Automobiles - Hot Rod Vehicles</option>
        <option value="27">Recreational Vehicle - 5th Wheels</option>
        <option value="32">Homes for Sale - Houses</option>
        <option value="33">Homes for Sale - Duplex</option>
        <option value="34">Homes for Sale - Townhouse</option>
        <option value="35">Homes for Sale - Condo</option>
        <option value="36">Homes for Sale - Mobile Homes</option>
        <option value="39">Housing Rentals - Apartments</option>
        <option value="40">Housing Rentals - Houses</option>
        <option value="41">Housing Rentals - Townhouse</option>
        <option value="42">Housing Rentals - Conda</option>
        <option value="43">Housing Rentals - Mobile Home</option>
        <option value="44">Housing Rentals - Duplex</option>                                                                                                                                                      ion value="44">Housing Rentals - Duplex</option>
        <option value="45">Upcoming Events - Lethbridge</option>
        <option value="46">Upcoming Events - Coaldale</option>
        <option value="47">Upcoming Events - Coalhurst</option>
        <option value="48">Upcoming Events - Taber</option>
        <option value="49">Upcoming Events - Fort McLeod</option>
        <option value="50">Upcoming Events - Surrounding Areas</option>
        <option value="51">Automotive Parts and Accessories - Used Parts</option>
        <option value="52">Automotive Parts and Accessories - New Parts</option>
        <option value="53">Motorcycles - ATV</option>
        <option value="54">Motorcycle Parts and Accessories - Apparel</option>
        <option value="55">Motorcycle Parts and Accessories - Helmuts</option>
        <option value="56">Motorcycle Parts and Accessories - Boots</option>
        <option value="58">Motorcycle Parts and Accessories - Equipment and Tools
        </option>
        <option value="59">Motorcycle and ATV Parts - New</option>
        <option value="22">Motorcycle - OFF ROAD</option>
        <option value="60">Motorcycle Parts and Accessories - Used</option>
        <option value="61">Houses for Sale - Acreages</option>
        <option value="62">Farm / Livestock / Equipment - Tractors</option>
        <option value="63">Farm / Livestock / Equipment - Tillers</option>
        <option value="64">Farm / Livestock / Equipment - Mowers</option>
        <option value="65">Farm / Livestock / Equipment - Livestock</option>
        <option value="66">Farm / Livestock / Equipment - Feed</option>
        <option value="71">Housing Rentals - Acreages</option>
        <option value="72">Employment Ads - Professional</option>
        <option value="73">Employment Ads - Trades</option>
        <option value="74">Employment Ads - General</option>
        <option value="149">Community Meetings</option>
        <option value="148">Tools</option>
        <option value="140">Bicycles - Single Speed</option>
        <option value="141">Bicycles - 10 Speed and Under</option>
        <option value="142">Bicycles - 18 Speed</option>
        <option value="143">Bicycles - Over 18 Speed</option>
        <option value="144">Bicycles - Unicycles</option>
        <option value="145">Bicycles - Scooters</option>
        <option value="146">Bicycles - Childrens Trikes</option>
        <option value="147">Bicycles - Children Bikes with Training Wheels</option>
        <option value="23">Motorcycle - Street Legal</option>
        <option value="24">Recreational Vehicle - Tent Trailer</option>
        <option value="25">Recreational Vehicle - Trailers</option>
        <option value="26">Recreational Vehicle - Motor Homes</option>
        </select></font>
   </td></p>
</tr>
<tr>
   <td><p><font face="Arial"><font size="2"<?php if(!$type) echo
        'class="error"'; ?>>Item Type:
   </td> </font>
   <td> <font size="2">&nbsp;
        <select size="1" name="item_type">
        <option selected value="1">Auction</option>
        <option value="2">Dutch Auction</option>
        <option value="3">Fixed Price</option>
        <option value="4">Classified Ad</option>
   </td></select></font>
   <td><font size="2"<?php if(!$quantity) echo 'class="error"'; ?>>
        &nbsp;&nbsp; Quantity:
   </td> </font>
   <td><font size="3">&nbsp;
   <td><input type="text" name="quantity_available" size="3"
       value="<?= $quantity_available ?>"
   </td></font>
   <td><font size="2"<?php if(!$price) echo 'class="error"'; ?>>
        &nbsp; Starting Bid:
   </td></font>
   <td> <input type="text" name="starting_bid" size="7"></font>
       <font size="2" value="<?= $starting_bid ?>"
   </td></font>
   <td> <font size="2"<?php if(!$increment) echo 'class="error"'; ?>>
        &nbsp;Bid Increment (auction only):
   </td></font>
   <td><input type="text" name="bid_increment" size="7"
         value="<?= $bid_increment ?>"
   </td></font>
   <td><font size="2"<?php if(!$reserve) echo 'class="error"'; ?>>
        &nbsp;&nbsp; Reserve Bid&nbsp;(auction only ):
   </td></font>
   <td><font size="2">&nbsp;<input type="text" name="reserve_price"
       size="7" value="<?= $reserve_price ?>"
   </td></font><font size="2"</font>
</tr>
<tr>
   <td><p><font face="Arial"><font size="2"<?php if(!$length)
        echo 'class="error"'; ?>>Ad Duration:&nbsp;
   </td>
   <td><select size="1" name="duration" value="<?= $duration ?>">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
        <option value="7">7</option>
        <option value="8">8</option>
        <option value="9">9</option>
        <option value="10">10</option>
        <option value="11">11</option>
        <option value="12">12</option>
        <option value="13">13</option>
        <option value="14" selected>14</option>
        <option value="15">15</option>
        <option value="16">16</option>
        <option value="17">17</option>
        <option value="18">18</option>
        <option value="19">19</option>
        <option value="20">20</option>
        <option value="21">21</option>
        <option value="22">22</option>
        <option value="23">23</option>
        <option value="24">24</option>
        <option value="25">25</option>
        <option value="26">26</option>
        <option value="27">27</option>
        <option value="28">28</option>
        <option value="29">29</option>
        <option value="30">30</option>
        </select>
   </td>
   <td><font face="Arial"><font size="2"<?php if(!$time) echo
        'class="error"'; ?>>&nbsp;&nbsp;&nbsp;&nbsp;End Time:
   </td>
   <td> <select size="1" name="end_hour" value="<?= $end_hour ?>">
        <option value="24">12:00 a.m.</option>
        <option value="1">1:00 a.m.</option>
        <option value="2">2:00 a.m.</option>
        <option value="3">3:00 a.m.</option>
        <option value="4">4:00 a.m.</option>
        <option value="5">5:00 a.m.</option>
        <option value="6">6:00 a.m.</option>
        <option value="7">7:00 a.m.</option>
        <option value="8">8:00 a.m.</option>
        <option value="9">9:00 a.m.</option>
        <option value="10">10:00 a.m.</option>
        <option value="11">11:00 a.m.</option>
        <option value="12">12:00 p.m.</option>
        <option value="13">1:00 p.m.</option>
        <option value="14">2:00 p.m.</option>
        <option value="15">3:00 p.m.</option>
        <option value="16">4:00 p.m.</option>
        <option value="17">5:00 p.m.</option>
        <option value="18">6:00 p.m.</option>
        <option value="19">7:00 p.m.</option>
        <option value="20" selected>8:00 p.m.</option>
        <option value="21">9:00 p.m.</option>
        <option value="22">10:00 p.m.</option>
        <option value="23">11:00 p.m.</option>
       </select
   </td>
   <td><font face="Arial"><font size="2"<?php if(!$relist) echo
        'class="error"'; ?>>&nbsp;&nbsp;&nbsp;&nbsp;Auto Relist:
   </td></font>
   <td><select size="1" name="auto_relist"value="<?= $auto_relist ?>">
        <option value="1" selected>Yes</option>
        <option value="0">No</option>
        </select>
   </td>&nbsp; </font>
   <td><font size="2"<?php if(!$ct) echo 'class="error"'; ?>>&nbsp; City:
   </td></font>
   <td> <font size="2">&nbsp;<input type="text" name="city" size="15"
        value="<?= $city ?>"
   </td></font>
   <td><font size="2"<?php if(!$prov) echo 'class="error"'; ?>>
        &nbsp;&nbsp;&nbsp; Province/State:
   </td></font>
   <td><font size="2"<?php if(!$state) echo 'class="error"'; ?>>
        &nbsp;<input type="text" name="state" size="10" value="<?= $state ?>"
   </td></font>
   <td><font size="2"<?php if(!$cntry) echo 'class="error"'; ?>>&nbsp;&nbsp; Country:
   </td></font>
   <td><font size="2"><select size="1" name="country"value="<?= $country ?>">
        <option selected value="32" >Canada</option>
        <option value="210">USA</option>
        </select>
   </td></font>
</tr>
<tr>
   <td><font size="2"<?php if(!$desc) echo 'class="error"'; ?>>
        &nbsp;&nbsp;&nbsp;&nbsp; </font></font><P>
        <font face="Arial"><font size="2">Item Description:
   </td></font>
   <td><font size="2">&nbsp;<textarea rows="4" name="item_description"
        cols="116"value="<?= $item_description ?>"
   </td></textarea></font></font></p>
</tr>
<tr>
      <td><p align="center"><font face="Arial"><font size="2"<?php if(!$pay) echo 'class="error"'; ?>>
      &nbsp;Paypal ID (Optional):</td>&nbsp;&nbsp;</font><td><font size="2"><input type="text"
      name="paypal_id" size="25" value="<?= $paypal_id ?>"</td></font>

      <td><font size="2"<?php if(!$hit) echo 'class="error"'; ?>>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
      Hit Counter:
   </td>&nbsp;&nbsp;</font><td><font size="3"><select size="1"
        name="hit_counter" value="<?= $hit_counter ?>">
       <option selected value="0">No Counter</option>
       <option value="1">Style 1</option>
       <option value="2">Style 2</option>
       <option value="3">Style 3</option>
       </select></font></font></p>
   </td>
</tr>
<hr>
<tr>
   <td>
       <p><b><font face="Arial" size="2">
       Please verify all details shown for your item
       before pressing the SAVE button.</font></b>
   </td>
   <td><input type="submit" name="Submit" value="SAVE  ITEM">
   </td> <font size="2">
</tr>
<tr>
   <td><BR>You will be guided through this Multi Step Process.  Please be sure
       to use the <B>same User ID</B> when entering your items or they will not all
       be listed correctly.</font></p>
   </td>
</tr>
</table>
</form>[/code]

Share this post


Link to post
Share on other sites
and here is the functions code

Have I made this way more complicated than it needs to be.  I hae a perfectly working copy of this form in an html file, but wanted to have it validate..... so perhaps the tutorial I watched wasn't the best way to do this..... not sure, but I can't see that it needs to be this complicated....maybe it is just me in that I don't understand alot of the terminology.

Ken

[code]<?php
function isDigits($element) {                      //numbers only
  return !preg_match ("/[^0-9]/", $element);
}
?>

<?php
function Dollars($element) {                        //numbers and decimal
  return !preg_match ("/[^0-9.]/", $element);
}
?>

<?php
function isLetters($element) {                      //letters only
  return !preg_match ("/[^A-z]/", $element);
}
?>

<?php
function LetandNumOnly($element) {                  //Letters and Numbers
  return !preg_match ("/[^A-z0-9]/", $element);    //with No Spaces
}
?>

<?php
function LettersAndDigits($element) {              //Letters, Numbers
  return !preg_match ("/[^A-z0-9 ]/", $element);  //and Spaces
}
?>

<?php
function Variable($element) {                      //letters, numbers, spaces
  return !preg_match ("/[^A-z0-9,. ]/", $element);//commas and periods only
}
?>

<?php
function checkLength($string, $min, $max) {        //Check the Length
  $length = strlen ($string);                      //min and max
  if (($length < $min) || ($length > $max)) {
    return FALSE;
  } else {
    return TRUE;
  }
}
?>

<?php
function checkMailCode($code, $country) {          //Check Postal Code
  $code = preg_replace("/[\s|-]/", "", $code);      //by Country
  $length = strlen ($code);
  switch (strtoupper ($country)) {
    case 'US':
      if (($length <> 5) && ($length <> 9)) {
        return FALSE;
      }
      return isDigits($code);
    case 'CA':
      if ($length <> 6) {
        return FALSE;
      }
      return preg_match ("/([A-z][0-9]){3}/", $code);
  }
}
?>

<?php
function checkURL($url) {                          //check valid URL Format
  return preg_match ("/http:\/\/(.*)\.(.*)/i", $url);
}
?>

<?php
function checkURLandConnect($url) {                //Check Valid URL and
  if (!preg_match ("/http:\/\/(.*)\.(.*)/i", $url)) {//Confirm by Connecting
    return FALSE;
  }
  $parts = parse_url($url);
  $fp = fsockopen($parts['host'], 80, $errno, $errstr, 10);
  if(!$fp) {
    return FALSE;
  }
  fclose($fp);
  return TRUE;
}
?>

<?php
function checkEmail($email) {                      //Check Email Format
  $pattern = "/^[A-z0-9\._-]+"
        . "@"
        . "[A-z0-9][A-z0-9-]*"
        . "(\.[A-z0-9_-]+)*"
        . "\.([A-z]{2,6})$/";
  return preg_match ($pattern, $email);
}
?>

<?php
function EmailorEmpty($element) {                    //Check Email Format
    if(empty($email)) {                            //or empty field
        return true;
    } else {
        $pattern = "/^[A-z0-9\._-]+"
        . "@"
        . "[A-z0-9][A-z0-9-]*"
        . "(\.[A-z0-9_-]+)*"
        . "\.([A-z]{2,6})$/";
        return preg_match ($pattern, $email);
    }
}
?>

<?php
function checkPassword($password) {                //check password for minimum
  $length = strlen ($password);                    //of 8 characters and must
  if ($length < 8) {                                //have a number between letters
    return FALSE;                                  //and a variation of letters
  }
  $unique = strlen (count_chars ($password, 3));
  $difference = $unique / $length;
  echo $difference;
  if ($difference < .60) {
    return FALSE;
  }
  return preg_match ("/[A-z]+[0-9]+[A-z]+/", $password);
}
?>

<?php
function BidIncrement($element)  {
  $bid_increment = $_POST['bid_increment'];  //function for bid_increment only
  $item_type = $_POST['item_type'];
  if($item_type == "Auction" or $item_type=="Dutch Auction")  {
    if(!(is_numeric($bid_increment))
    OR empty($bid_increment)){
      echo "You have not entered a valid Bid Increment";
      exit;
    }
    else{
    echo "Valid bid increment";
  }
}
elseif($item_type == "fixed price" OR $item_type="classified"){
  if(!empty($bid_increment)){
    echo "Bid Increments are not valid for this type of Listing!";
}
}
}
?>

<?php
function ReservePrice($element)    {
  $reserve_price = $_POST['reserve_price'];  //function for reserve_price only
  $item_type = $_POST['item_type'];
  if($item_type == "Auction" or $item_type=="Dutch Auction")  {
    if(!(is_numeric($reserve_price))
      OR empty($reserve_price)){
        echo "You have not entered a Valid Reserve Bid or Starting Price";
        exit;
      }
      else{
        echo "Valid Reserve Bid or Starting Price";
      }
    }
    elseif($item_type == "Fixed Price" OR $item_type="Classified Ad"){
      if(!empty($reserve_price)){
        echo "A Reserve Bid or Starting Price cannot be entered for this auction type";
}
}
}
?>
<?php
function ItemCategory($element)    {          // Verify Valid Category
  $item_category = $_POST['item_category'];
  if($item_category == "000")//assumes you gave it the value 000
  {
    return FALSE;
    echo "Please select a valid category";
    exit;
}
}

?>[/code]

Share this post


Link to post
Share on other sites
The form's method is "POST" which is OK. The action says "sample.php". Is that the name of your validation script?

This line
[code] <?php echo '<pre>' . print_r($_POST,true) . '</pre>'; ?>[/code]
should be at tbe start of your validation script, not in your form.

Ken

Share this post


Link to post
Share on other sites
That is the name of the file that has both the form and the validation script in it.  It is one file with both parts in it and then I have a separate file called functions.php which has the various functions in it.

Share this post


Link to post
Share on other sites
That is where I had it when the array (  ) came up, then I moved it thinking I might have it in the wrong spot

Ken

Would I then run the script and see what happens?  That is when I got the above line

Ken

Share this post


Link to post
Share on other sites
I am grasping at straws here, but when I have the print_r at the very top and run it, I get
array
(
)

When I change it from true to false, I get
array ()

1 (a smaller sized 1)

Don't know if this helps

Ken

Share this post


Link to post
Share on other sites
The "true" just says to put the output to a string which the echo just puts out between the [code]<pre></pre>[/code] tags.

I'm about to go to sleep (it's almost 1 am here & I have to get up at 6) now... If you send me all of the relevant files to my email address, I will take a look at them on my own server.

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.