Jump to content


Photo

Validation Script only validating one field


  • Please log in to reply
No replies to this topic

#1 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 13 July 2006 - 02:25 PM

I have the validation script to the point of not generating errors, but when I try it out, it only validates on field (there are 16).  For some reason it is validating the 3rd field which is called item_category.  This field is a drop down box, and the two fields before it are text boxes.  I have included the code up to and including the 3rd field. (to save room)

<?php
/* validation.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) {
        echo "Form filled successfully!";
        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 = '';
}
?>
<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="uploadformcomplete.php">
<HR>
<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>

Thanks for the help

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users