Jump to content

kenwvs

Members
  • Posts

    194
  • Joined

  • Last visited

    Never

Everything posted by kenwvs

  1. I have had a friend build a php page, with a form in it.  I am thinking he has used CSS for the formatting of it, and all of the text and the form fields stay in nice block format.  I would like them not to do that, is there a way to change that, and I hope you can tell from the code I have provided. Ken [code] <html> <head> <title>For Sale 4 U QUICK LISTER</title> <style type="text/css"> body {         background-color: Gainsboro;         margin: 0;         padding: 0;         font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;         font-size: 75%;         color: black; } table {         width: 96%;         display: block;         margin-left: auto;         margin-right: auto; } form {         width: 98%;         display: block;         margin-left: auto;         margin-right: auto; } .red {         color: Red; } .error {color:#C03; font-weight:bold; } h3 {         text-align: center;         color: Red;         font-weight: bold; } h4 {         text-align: center;         color: Blue;         font-weight: bold; } .center {         text-align: center; } .bold {         font-weight: bold; } [/code]
  2. Sometimes when you complete a form you have to enter a random code of numbers and letters to make sure that you are human.... what is this called and is it done in PHP or some other language? I have an online order form that we want to look at implementing this and am wondering if this is a complicated process? thanks, Ken
  3. It is definetely a form all on its own, so since the night isn't getting any younger, I guess, I will get oto work on it. Ken
  4. I have created an HTML form and one of the fields is a drop down menu with about 50 -60 choices, and in my infinite wisdom, when I created it, I created the order based on the option value, instead of the alphabetical name. Is there any easy way to ask for this to list them in an alphabetical order, or will I spend my Saturday evening, organizing them alphabetically. thanks, Ken
  5. The following is part of a file and I am wondering what the form.sb_buynow_price.value! means.  Is it referincing to another file, or is that a command to make something work? It is a buy now feature in an auction program and the buy now was working, and I paid someone to do some upgrades, and now the buy now feature appears when listing an item, but doesn't appear to th buyer to make a purchase.  I am thinking the stuff lower down that is referenced out (*/) is because I didn't want paypal to be a condition, but an option, so it was changed. Thanks, Ken if(form.sb_buynow_price.value!='')                 {                         if(isNaN(form.sb_buynow_price.value) || form.sb_buynow_price.value <= 0 )                         {                                 alert("Please specify positive nonzero value for Buy Now Price");                                 form.sb_buynow_price.focus();                                 return false;                         }                 /*        if( form.paypal_id.value=='')                ------disabled                         {                                 alert("You must specify Paypal Id for buy now option to work");                                 form.paypal_id.focus();                                 return false;                         }                         if (!emailCheck (form.paypal_id.value) )                         {                                 form.paypal_id.focus();                                 return (false);                         }*/                 }
  6. Is the following a bad choice in how I am getting my form validation done?  I got it from a tutorial, but am not having much success in getting it to work, so am wondering if it is more complicated than it needs to be, and I should quit trying to figure out why this won't work, and move on to a different method? Ken <?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 = ''; } ?>
  7. When i load my script up on my local server (WAMP5) setup, I am getting the following item in all of my forms (where the results normally go), and am wondering if this is normal or I have an error along the way. They all show <?= $quantity_available ?>, where the actual wording is the same as whatever is in the value field, in the form. <td> <font size="2">&nbsp;    <td> <input type="text" name="quantity_available" size="3"         value="<?= $quantity_available ?>">    </td></font> Is this normal or have I got something not quite right?  If this is normal, would it appear normally when loaded onto the normal server, as this appears wherever you would normally fill in the blanks. Thanks, Ken
  8. 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
  9. 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
  10. 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.
  11. 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]
  12. 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]
  13. 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>
  14. 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
  15. 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
  16. 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]
  17. 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) [code] <?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> [/code] Thanks for the help Ken
  18. Thanks for the tips, they are appreciated.  A question for clarification please. You are correct that these functions will be used with another script (different page).  Is it a good idea to include these in the same page, or keep them separate.  I followed through a tutorial on form validation (from a different site) and they suggested keeping it separate so I can reuse these functions on different pages in the future. If these functions will be used to validate a page, but each one is independent of the others, can I still eliminate all of the <?php and ?> tags? Thanks for the help Ken
  19. look at the original script posted and how all the brackets are at the edge, and then look at the example with the correction, how the brackets are indented.  The indentations all go together with the bracket, so you can then see where the brackets start and stop, and you can tell if you are missing one.
  20. On the program I did indent, haven't done this one yet, as I have been up all night trying to figure it all out.  This is the first script I have really written, and am going to indent this yet.
  21. [code] <HTML> <BODY> <?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($email) {                    //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($bid)  { $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($reserve)    { $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 bid increment";   } }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($category)    {          // Verify Valid Category $item_category = $_POST['item_category']; if($item_category == "000")//assumes you gave it the value 000 { echo "Please select a valid category"; exit; } } ?> </BODY> </HTML> [/code]
  22. This is the last function in my file, and this error is coming up on the last line, which contains just the ?> If I remove this function, then it gives me the error at the end of the previous one, so I am thinking it might have to do with not ending the file.  I have tried putting </Body> and </HTML> as they are also at the start of the file, and then I tried deleting them from the start and end, but no luck....Looking for an idea on this. thanks, Ken [code] <?php function ItemCategory($category)    {          // Verify Valid Category $item_category = $_POST['item_category']; if($item_category == "000")//assumes you gave it the value 000 { echo "Please select a valid category"; exit; } } ?> [/code]
  23. These are the functions that I am using in my form.  I am not sure if I have written them correctly or not, as I got the gist of it from a tutorial at another site, and then went out on my own.  If you want to browse and let me know where I have gone wrong that would be great. I have a feeling this tutorial that is for form validation may not have taken the most direct route, so it may not look totally normal. Thanks in advance, 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($email) {                    //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($bid)  { $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($reserve)    { $reserve_price = $_POST['reserve_price'];  //function for reserve_price only $item_type = $_POST['item_type']; if($item_type == "Auction" or $item_type=="Ddutch 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 bid increment";   } }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($category)    {          // Verify Valid Category $item_category = $_POST['item_category']; if($item_category == "000")//assumes you gave it the value 000 { echo "Please select a valid category"; exit; } } ?> [/code]
  24. Positive versus Negative Depending on whether you want it to come back true or false?
  25. I have written the following function, hoping to achieve that it will only allow letters, numbers, spaces, comma, and period.  I don;t want it to allow any special characters like & $ brackets *  All the shift number characters basically need to be disallowed. [code] <?php function Variable($element) {                       //letters, numbers, spaces   return !preg_match ("/[^A-z0-9,.] /", $element);//commas and periods only } ?> [/code] Thanks, Ken
×
×
  • Create New...

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.