Jump to content


Photo

PHP Form not processing


  • Please log in to reply
58 replies to this topic

#21 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 July 2006 - 02:02 AM


if (isset ($_POST['Submit'])) {
	$valid = true;
	foreach($_POST as $key=>$val) {
		if ($key != 'Submit') {
			switch ($funcs[$key]) {
				case 'LettersAndDigits':
					if (!LettersAndDigits($val)) $err[] = $key;
					break;
				case 'Variable':
					if (!Variable($val)) $err[] = $key;
					break;
				case 'Dollars':
					if (!Dollars($val)) $err[] = $key;
					break;
				case 'ItemCategory':
					$ic = ItemCategory($val);
					if (!$ic[0]) {
						$err[] = $key;
						$err_msg[$key] = $ic[1];
					}
					break;
				case 'isDigits':
					if (!isDigits($val)) $err[] = $key;
					break;
				case 'EmailorEmpty':
					if (!EmailorEmpty($val)) $err[] = stripslashes($key);
					break;
				case 'BidIncrement':
					$bi = BidIncrement($val,$itemType[$_POST['item_type']]);
					if (!$bi[0]) {
						$err[] = $key;
						$err_msg[$key] = $bi[1];
					}
					break;
				case 'ReservePrice':
					$rp = ReservePrice($val,$itemType[$_POST['item_type']]);
					if (!$rp[0]) {
						$err[] = $key;
						$err_msg[$key] = $rp[1];
					}
					break;
			}
		}
		
		if (!empty($err)) $valid = false;
	}

    if ($valid) {?>

	    
<script type="text/javascript">
       window.location.href='upload2.php';
       </script>
<?

        exit;
    }

}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#22 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 20 July 2006 - 02:04 AM

Sorry to sound stupid, but the only line that matters is the line directly above the end php?> statement  If there is space in other lines then it is ok. 

I have tried reading through the PHP manual (or whateveri t is called) and find it confusing.  Is there a tutorial where you actually build something that would make it all clearer.

#23 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 20 July 2006 - 02:08 AM

RedArrow - Could you explain for me what you have changed in your last post.  I appreciate that you have changed the header info, but can you tell me why and what the difference will be (other than it will work)  I am really trying to understand this, not just change it, although I do appreciate the thought of getting it to work.

#24 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 July 2006 - 02:08 AM

did my code work cheers.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#25 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 20 July 2006 - 02:11 AM

this produces the following error.......it is two lines after the last line of </html>

Parse error: parse error, unexpected $end in C:\wamp\www\uploadform.php on line 457

#26 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 July 2006 - 02:14 AM

Ken,

Can you post your uploadform.php in it's entirety?

#27 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 20 July 2006 - 02:15 AM

Do you want it with the last change that RedArrow had me try, or with the way it was before.

#28 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 20 July 2006 - 02:19 AM

<?php
/* uploadform.php */

require_once ('functions.php');
$categories = array("000" =>'Please Select Category',
                               "150" =>'Antiques',
                               113 =>"Arts and Crafts",
                                20 =>"Automobiles - Antique Vehicles",
                                18 =>"Automobiles - Cars",
                                21 =>"Automobiles - Hot Rod Vehicles",
                                19 =>"Automobiles - Trucks",
                                52 =>"Automotive Parts and Accessories - New Parts",
                                51 =>"Automotive Parts and Accessories - Used Parts",
                               134 =>"Automotive Stereos and Radar Detectors",
                               140 =>"Bicycles - Single Speed",
                               141 =>"Bicycles - 10 Speed and Under",
                               142 =>"Bicycles - 18 Speed",
                               143 =>"Bicycles - Over 18 Speed",
                               144 =>"Bicycles - Unicycles",
                               145 =>"Bicycles - Scooters",
                               146 =>"Bicycles - Childrens Trikes",
                               147 =>"Bicycles - Children Bikes with Training Wheels",
                                84 =>"Cameras - Digital Camera",
                                85 =>"Cameras - Camcorders",
                                86 =>"Cameras - Others",
                               167=>"Collector Coins",
                               149 =>"Community Meetings",
                                87 =>"Computers and Accessories - Monitors",
                                88 =>"Computers and Accessories - Printers",
                                89 =>"Computers and Accessories - CPU's",
                                90 =>"Computers and Accessories - Complete Systems",
                                91 =>"Computers and Accessories - Accessories",
                               103 =>"Computers and Accessories - Services",
                               105 =>"Construction - Services",
                               106 =>"Construction - Equipment",
                               107 =>"Construction - Tools",
                               109 =>"Construction - Products - New",
                               110 =>"Construction - Products - Used",
                                74 =>"Employment Ads - General",
                               120 =>"Employment Ads - General Labourer",
                                72 =>"Employment Ads - Professional",
                               119 =>"Employment Ads - Restaurant",
                               118 =>"Employment Ads - Retail",
                                73 =>"Employment Ads - Trades",
                                66 =>"Farm / Livestock / Equipment - Feed",
                                65 =>"Farm / Livestock / Equipment - Livestock",
                                64 =>"Farm / Livestock / Equipment - Mowers",
                                63 =>"Farm / Livestock / Equipment - Tillers",
                                62 =>"Farm / Livestock / Equipment - Tractors",
                               168 =>"Health and Wellness",
                                96 =>"Home Electronics - DVD and VCR",
                                92 =>"Home Electronics - Gaming Machines",
                                97 =>"Home Electronics - MP3, Discman, etc.",
                               135 =>"Home Electronics - Telephone",
                                77 =>"Home and Garden - Gardening Tools and small equipment",
                                75 =>"Home and Garden - Lawnmowers",
                                76 =>"Home and Garden - Rototillers",
                                78 =>"Home and Garden - Services",
                                79 =>"Home and Garden - Sheds",
                               154 =>"Household Goods - Appliances",
                               155 =>"Household Goods - Bar - B - Q",
                               156 =>"Household Goods - Bedroom Furniture",
                               152 =>"Household Goods - Furniture",
                               151 =>"Household Goods - Kitchen",
                               153 =>"Household Goods - Small Appliances",
                               154 =>"Household Goods - Appliances",
                                61 =>"Houses for Sale - Acreages",
                                35 =>"Homes for Sale - Condo",
                                33 =>"Homes for Sale - Duplex",
                                32 =>"Homes for Sale - Houses",
                                36 =>"Homes for Sale - Mobile Homes",
                                34 =>"Homes for Sale - Townhouse",
                                71 =>"Housing Rentals - Acreages",
                                39 =>"Housing Rentals - Apartments",
                                42 =>"Housing Rentals - Condo",
                                44 =>"Housing Rentals - Duplex",
                                40 =>"Housing Rentals - Houses",
                                43 =>"Housing Rentals - Mobile Home",
                                41 =>"Housing Rentals - Townhouse",
                               132 =>"Jewellery and Watches - Beaded Jewellery",
                               131 =>"Jewellery and Watches - Rings",
                               133 =>"Jewellery and Watches - Engagement and Wedding",
                               130 =>"Jewellery and Watches - Watches",
                                53 =>"Motorcycles - ATV",
                                22 =>"Motorcycle - OFF ROAD",
                                23 =>"Motorcycle - Street Legal",
                                54 =>"Motorcycle Parts and Accessories - Apparel",
                                56 =>"Motorcycle Parts and Accessories - Boots",
                                58 =>"Motorcycle Parts and Accessories - Equipment and Tools",
                                55 =>"Motorcycle Parts and Accessories - Helmuts",
                                59 =>"Motorcycle and ATV Parts - New",
                                60 =>"Motorcycle Parts and Accessories - Used",
                               137 =>"Personal Care Products",
                               121 =>"Pets",
                                27 =>"Recreational Vehicle - 5th Wheels",
                                26 =>"Recreational Vehicle - Motor Homes",
                                24 =>"Recreational Vehicle - Tent Trailer",
                                25 =>"Recreational Vehicle - Trailers",
                               159 =>"Renovations - Bathroom",
                               162 =>"Renovations - Bedroom",
                               164 =>"Renovations - Electrical",
                               160 =>"Renovations - Kitchen",
                               161 =>"Renovations - Living Areas",
                               163 =>"Renovations - Plumbing",
                               165 =>"Renovations - Wholesalers",
                               165 =>"Services - Child Care",
                               127 =>"Services - Moving and Storage",
                               122 =>"Services - Professional",
                               123 =>"Services - Tradesman",
                               126 =>"Services - Yard Care and Snow Removal",
                               166 =>"Services - Renovation Contractors",
                                95 =>"Stereos - All in One",
                                94 =>"Stereos - Components",
                                93 =>"Stereos - Speakers",                                                                            98 =>"Televisions - Flat Screen",
                                98 =>"Televisions - Flat Screen",
                                99 =>'Televisions - Under 20"',
                               100 =>"Televisions - 20 inch and over",
                               101 =>"Televisions - Plasma",
                               102 =>"Televisions - Projection",
                               148 =>"Tools",
                               138 =>"Toys",
                                46 =>"Upcoming Events - Coaldale",
                                47 =>"Upcoming Events - Coalhurst",
                                49 =>"Upcoming Events - Fort McLeod",
                                45 =>"Upcoming Events - Lethbridge",
                                48 =>"Upcoming Events - Taber",
                                50 =>"Upcoming Events - Surrounding Areas",
                               128 =>"WANT ADS");
$valid = TRUE;
$err = array();
$err_msg = array();
$funcs = array('id'=>'LettersAndDigits',
                                        'item_title' => 'Variable',
                                        'item_category'=>'ItemCategory',
                                        'item_type' => 'Variable',
                                        'quantity_available' => 'isDigits',
                                        'starting_bid' => 'Dollars',
                                        'bid_increment' => 'BidIncrement',
                                        'reserve_price' => 'ReservePrice',
                                        'duration' => 'isDigits',
                                        'end_time' => 'isDigits',
                                        'auto_relist' => 'isLetters',
                                        'city' => 'Variable',
                                        'state' => 'Variable',
                                        'country' => 'Variable',
                                        'item_description' => 'Variable',
                                        'paypal_id' => 'EmailorEmpty',
                                        'hit_counter' => 'Variable');
$hc = array(0=> 'No Counter',
            1=> 'Style 1',
            2=> 'Style 2',
            3=> 'Style 3');
$itemType = array(1=> 'Auction',
                  2=> 'Dutch Auction',
                  3=> 'Fixed Price',
                  4=> 'Classified Ad');
$countries = array(32=>'Canada',210=>'USA');
$yesno = array(1=>'Yes',0=>'No');
$hours = array(24 =>'12:00 a.m.',
                                        1 =>'1:00 a.m.',
                                        2 =>'2:00 a.m.',
                                        3 =>'3:00 a.m.',
                                        4 =>'4:00 a.m.',
                                        5 =>'5:00 a.m.',
                                        6 =>'6:00 a.m.',
                                        7 =>'7:00 a.m.',
                                        8 =>'8:00 a.m.',
                                        9 =>'9:00 a.m.',
                                        10 =>'10:00 a.m.',
                                        11 =>'11:00 a.m.',
                                        12 =>'12:00 p.m.',
                                        13 =>'1:00 p.m.',
                                        14 =>'2:00 p.m.',
                                        15 =>'3:00 p.m.',
                                        16 =>'4:00 p.m.',
                                        17 =>'5:00 p.m.',
                                        18 =>'6:00 p.m.',
                                        19 =>'7:00 p.m.',
                                        20 =>'8:00 p.m.',
                                        21 =>'9:00 p.m.',
                                        22 =>'10:00 p.m.',
                                        23 =>'11:00 p.m.');

if (isset ($_POST['Submit'])) {
        $valid = true;
        foreach($_POST as $key=>$val) {
                if ($key != 'Submit') {
                        switch ($funcs[$key]) {
                                case 'LettersAndDigits':
                                        if (!LettersAndDigits($val)) $err[] = $key;
                                        break;
                                case 'Variable':
                                        if (!Variable($val)) $err[] = $key;
                                        break;
                                case 'Dollars':
                                        if (!Dollars($val)) $err[] = $key;
                                        break;
                                case 'ItemCategory':
                                        $ic = ItemCategory($val);
                                        if (!$ic[0]) {
                                                $err[] = $key;
                                                $err_msg[$key] = $ic[1];
                                        }
                                        break;
                                case 'isDigits':
                                        if (!isDigits($val)) $err[] = $key;
                                        break;
                                case 'EmailorEmpty':
                                        if (!EmailorEmpty($val)) $err[] = stripslashes($key);
                                        break;
                                case 'BidIncrement':
                                        $bi = BidIncrement($val,$itemType[$_POST['item_type']]);
                                        if (!$bi[0]) {
                                                $err[] = $key;
                                                $err_msg[$key] = $bi[1];
                                        }
                                        break;
                                case 'ReservePrice':
                                        $rp = ReservePrice($val,$itemType[$_POST['item_type']]);
                                        if (!$rp[0]) {
                                                $err[] = $key;
                                                $err_msg[$key] = $rp[1];
                                        }
                                        break;
                        }
                }

                if (!empty($err)) $valid = false;
        }

    if ($valid) {
            header ("Location: upload2.php");
        exit;
    }

}
function disp_val($idx) {
        $retv = '';
        if (isset($_POST[$idx])) $retv = stripslashes($_POST[$idx]);
        return($retv);
}

function is_selected($it,$val,$def='') {
        if (isset($_POST[$it]))
                $ret =($_POST[$it] == $val)?' selected ':'';
        else
                $ret = ($val == $def)?' selected':'';
        return($ret);
}

function disp_options($opt_array,$fld,$def,$for_type) {
        $tmp = array();
        if ($for_type)
                foreach ($opt_array as $key=>$val)
                        $tmp[] = '<option value="' . $key . '"' . is_selected($fld,$key,$def) . '>' . $val . '</option>';
        else
                for ($i=0;$i<count($opt_array);$i++)
                        $tmp[] = '<option value="' . $i . '"' . is_selected($fld,$i,$def) . '>' . $opt_array[$i] . '</option>';
        echo "\t\t" . implode("\n\t\t",$tmp) . "\n";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<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: 72%;
        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;
 }
</style>
</head>
<body>
<h3>Quick Lister</h3>
<p class="center"><span class="red">For Sale 4 U - Canada's Online Auction</span></p>
<p class="center"><span class="bold">Please note:&nbsp; </span>You may
not use characters such as $, #, &quot;, &amp;, *,/, etc.&nbsp; It is best to use normal
text and numerical characters only.&nbsp;<BR><BR><BR>
<?php
$trace = array();
if (!$valid) {
?>
<h4>Please correct the items in <span class="error">red</span> and resubmit.<br /><br /> </h4>
<?php
}
?>
<HR>
<form method="POST" action="uploadform.php">
<table>
<tr>
    <td valign="top" <?php if(in_array('id',$err)) echo 'class="error"'; ?>> User ID:</td>
    <td><input type="text" name="id" size="12" value="<?php echo  disp_val('id') ?>"><br>
    You must use the <span class="bold">same User ID</span> for all items you are uploading during this session.(It does not have to be your regular username.)</td>
</tr>
<tr>
    <td <?php if(in_array('item_title',$err)) echo 'class="error"'; ?>>  Item Title:</td>
    <td><input type="text" name="item_title" size="60" value="<?php echo  disp_val('item_title'); ?>"</td>
</tr>
<tr>
    <td <?php if(in_array('item_category',$err)) echo 'class="error"'; ?>>Item Category:</td>
    <td> <select size="1" name="item_category">
         <?php disp_options($categories,'item_category','',true) ?>
          </select>
          <? if (isset($err_msg['item_category'])) echo '&nbsp;<span
          class="error">' . $err_msg['item_category'] . '</span>'; ?>
          </td></p>
</tr>
<tr>
    <td <?php if(in_array('item_type',$err)) echo 'class="error"'; ?>>Item Type:</td>
    <td><select size="1" name="item_type">
         <?php
                         $tmp = array();
                        for ($i=1;$i<count($itemType)+1;$i++)
                                $tmp[] = '<option value="' . $i . '"' . is_selected('item_type',$i,0) . '>' . $itemType[$i] . '</option>';
                        echo "\t\t" . implode("\n\t\t",$tmp) . "\n";
        ?>
    </td></select>
</tr>
<tr><td <?php if(in_array('quantity_available',$err)) echo 'class="error"'; ?>>Quantity:</td>
    <td><input type="text" name="quantity_available" size="3" value="<?php echo  disp_val('quantity_available') ?>"</td></tr>
</tr>
<tr>
    <td <?php if(in_array('starting_bid',$err)) echo 'class="error"'; ?>>Starting Bid:</td>
    <td> <input type="text" name="starting_bid" size="7" value="<?php echo  disp_val('starting_bid') ?>"></td>
</tr>
<tr>
    <td <?php if(in_array('bid_increment',$err)) echo 'class="error"'; ?>>Bid Increment (auction only):</td>
    <td><input type="text" name="bid_increment" size="7" value="<?php echo  disp_val('bid_increment') ?>"><? if (isset($err_msg['bid_increment'])) echo '&nbsp;<span class="error">' . $err_msg['bid_increment'] . '</span>'; ?></td>
</tr>
<tr>
    <td <?php if(in_array('reserve_price',$err)) echo 'class="error"'; ?>>Reserve Bid&nbsp;(auction only ):</td>
    <td><input type="text" name="reserve_price" size="7" value="<?php echo  disp_val('reserve_price') ?>"><? if (isset($err_msg['reserve_price'])) echo '&nbsp;<span class="error">' . $err_msg['reserve_price'] . '</span>'; ?></td>
</tr>
<tr>
    <td <?php if(in_array('duration',$err)) echo 'class="error"'; ?>>Ad Duration:</td>
    <td><select size="1" name="duration">
         <?php $tmp = array();
                 for ($d=1;$d<31;$d++)
                         $tmp[] = '<option value="' . $d . '"' . is_selected('duration',$d,'14') .'>' . $d . '</option>';
                echo "\t\t" . implode("\n\t\t",$tmp) . "\n";
                ?>
         </select>
    </td>
</tr>
<tr>
    <td <?php if(in_array('end_hour',$err)) echo 'class="error"'; ?>>End Time:</td>
    <td> <select size="1" name="end_hour">
         <?php disp_options($hours,'end_hour',20,true); ?>
        </select>
    </td>
</tr>
    <tr><td <?php if(in_array('auto_relist',$err)) echo 'class="error"'; ?>>Auto Relist:</td>
    <td><select size="1" name="auto_relist">
         <?php disp_options($yesno,'auto_relist',1,true); ?>
         </select>
    </td>
</tr>
<tr>
    <td <?php if(in_array('city',$err)) echo 'class="error"'; ?>>City:</td>
    <td><input type="text" name="city" size="15" value="<?php echo  disp_val('city') ?>"> </td>
</tr>
<tr>
    <td <?php if(in_array('state',$err)) echo 'class="error"'; ?>>Province/State:</td>
    <td><input type="text" name="state" size="10" value="<?php echo  disp_val('state') ?>"></td>
</tr>
<tr>
    <td <?php if(in_array('country',$err)) echo 'class="error"'; ?>>Country:</td>
    <td><select size="1" name="country">
                 <?php disp_options($countries,'country',32,true) ?>
                </select>
    </td>
</tr>
<tr>
    <td valign="top" <?php if(in_array('item_description',$err)) echo 'class="error"'; ?>>Item Description:</td>
    <td colspan=8><textarea rows="4" name="item_description" cols="116"><?php echo  disp_val('item_description') ?></textarea></td>
</tr>
<tr>
       <td <?php if(in_array('paypal_id',$err)) echo 'class="error"'; ?>>Paypal ID (Optional):</td>
                 <td><input type="text" name="paypal_id" size="25" value="<?php echo  disp_val('paypal_id') ?>">
</tr>
<tr>
       <td <?php if(in_array('hit_counter',$err)) echo 'class="error"'; ?>>Hit Counter:</td>
                 <td><select size="1" name="hit_counter">
                 <?php disp_options($hc,'hit_counter',0,true); ?>
        </select>
    </td>
</tr>
</tr>
        <td colspan="2"><hr></td>
<tr>
<tr>
    <td colspan="5" class="center">
        <span class="bold"><br>Please verify all details shown for your item before pressing the SAVE button.</span>
    </td>
</tr>
<tr>
    <td colspan="5" class="center"><br><input type="submit" name="Submit" value="SAVE  ITEM"></td>
</tr>
<tr>
    <td colspan="2" class="center"><BR>You will be guided through this Multi Step Process.  Please be sure
        to use the <span class="bold">same User ID</span> when entering your items or they will not all
        be listed correctly.</font></p>
    </td>
</tr>
</table>
</form>
</body>
</html>



#29 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 20 July 2006 - 02:20 AM

That is the complete upload.php code.  I didn't find any whitespace, etc....(from a real beginners set of eyes)

#30 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 July 2006 - 02:21 AM




if (isset ($_POST['Submit'])) {
	$valid = true;
	foreach($_POST as $key=>$val) {
		if ($key != 'Submit') {
			switch ($funcs[$key]) {
				case 'LettersAndDigits':
					if (!LettersAndDigits($val)) $err[] = $key;
					break;
				case 'Variable':
					if (!Variable($val)) $err[] = $key;
					break;
				case 'Dollars':
					if (!Dollars($val)) $err[] = $key;
					break;
				case 'ItemCategory':
					$ic = ItemCategory($val);
					if (!$ic[0]) {
						$err[] = $key;
						$err_msg[$key] = $ic[1];
					}
					break;
				case 'isDigits':
					if (!isDigits($val)) $err[] = $key;
					break;
				case 'EmailorEmpty':
					if (!EmailorEmpty($val)) $err[] = stripslashes($key);
					break;
				case 'BidIncrement':
					$bi = BidIncrement($val,$itemType[$_POST['item_type']]);
					if (!$bi[0]) {
						$err[] = $key;
						$err_msg[$key] = $bi[1];
					}
					break;
				case 'ReservePrice':
					$rp = ReservePrice($val,$itemType[$_POST['item_type']]);
					if (!$rp[0]) {
						$err[] = $key;
						$err_msg[$key] = $rp[1];
					}
					break;
			}
		}
		
		if (!empty($err)) $valid = false;
	}

    if ($valid) {?>

	    
<meta http-equiv="refresh" content="0;url=upload2.php" />
<?

        exit;
    }

}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#31 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 July 2006 - 02:24 AM

does it work know cheers just alter the code ok above
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#32 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 20 July 2006 - 02:25 AM

Parse error: parse error, unexpected $end in C:\wamp\www\uploadform.php on line 455

is the error this produces..... two lines after the end of the code

#33 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 July 2006 - 02:32 AM

Your file works for me, but I'm not including the functions.php.  Is there any whitespace in that file?  The only place I can see a problem would be in one of the validation functions, which it's probably unlikely, or at the top of your functions.php....
<<BOF>>

<?php

....function code here...

?>
<<EOF>>


hehe...from the manual:

It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called.



#34 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 20 July 2006 - 02:34 AM

here is the functions code


<?php
function isDigits($element) {                       //numbers only
  if (strlen(stripslashes(trim($element))) == 0)
     return (false);
  return !preg_match ("/[^0-9]/", $element);
  }

function Dollars($element) {                        //numbers and decimal
  if (strlen(stripslashes(trim($element))) == 0)
     return (false);
  return !preg_match ("/[^0-9.]/", $element);
}

function isLetters($element) {                      //letters only
  if (strlen(stripslashes(trim($element))) == 0)
     return (false);
  return !preg_match ("/[^A-z]/", $element);
}

function LetandNumOnly($element) {                  //Letters and Numbers
  if (strlen(stripslashes(trim($element))) == 0)    //with No Spaces
     return (false);
  return !preg_match ("/[^A-z0-9]/", $element);
}

function LettersAndDigits($element) {               //Letters, Numbers
  if (strlen(stripslashes(trim($element))) == 0)    //and Spaces
     return (false);
  return !preg_match ("/[^A-z0-9 ]/", $element);
}

function Variable($element) {                       //letters, numbers, spaces
  if (strlen(stripslashes(trim($element))) == 0)    //commas and periods only
     return (false);
  return !preg_match ("/[^A-z0-9,.? ]/", $element);

}

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

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);
  }
}

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

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;
}

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);
}

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);
    }
}

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;
  if ($difference < .60) {
    return FALSE;
  }
  return preg_match ("/[A-z]+[0-9]+[A-z]+/", $password);
}

function BidIncrement($bi,$it)   {
        $ret = array(true,'');
  if($it == "Auction" || $it =="Dutch Auction")  {
    if(!(is_numeric($bi)) || empty($bi)){
        $ret = array(false, "You have not entered a valid Bid Increment");
      }
        }
    elseif($it == "Fixed Price" || $it =="Classified Ad"){
      if(!empty($bi)){
                        $ret = array(false, "A Bid Increment cannot be entered for this type of listing.");
                }
        }
        return ($ret);
}

function ReservePrice($rp,$it)     {
        $ret = array(true,'');
  if($it == "Auction" || $it =="Dutch Auction")  {
    if(!(is_numeric($rp)) || empty($rp)){
        $ret = array(false, "You have not entered a Valid Reserve Bid or Starting Price");
      }
        }
    elseif($it == "Fixed Price" || $it =="Classified Ad"){
      if(!empty($rp)){
                        $ret = array(false, "A Reserve Bid cannot be entered for this type of listing");
                }
        }
        return ($ret);
}

function ItemCategory($element)    {    // Verify Valid Category
   if($element == "000")               //assumes you gave it the value 000
     return array(FALSE, "Please select a valid category");
   else
     return array(TRUE);
}
?>



#35 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 20 July 2006 - 02:35 AM

You said it was working.  Was that using the complete code I just sent?  if it was in the functions.php, wouldn't I get an error when it tries to validate, which is working fine.

Ken

#36 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 July 2006 - 02:41 AM

I'm at a loss.  The only thing I see is at the top of the code block is an empty line, which may be a result of how you put the code tags around the block of code, and not a part of the file at all.

I don't see a single place where it is outputting data to the browser...maybe I'm tired...

If all else fails, use output buffering...at the very top of your page, put ob_start();.  Then at the very bottom of the page put ob_end_flush();.  What that does is buffer all of the output to the browser until the ob_end_flush is called.  This means that when the header is called, it ensures that nothing has been sent to the browser.

I don't really like that solution, because it doesn't solve the problem.  Your code looks good to me...a lot better than most...I'm completely missing why it is not redirecting.

#37 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 July 2006 - 02:43 AM

Why your code
does not work god knows but heres an emple trying to
achive for your code but no luck sorry.






This will work as the name is redarrow.
<?

$name="redarrow";

if($name="redarrow"){
?>

<meta http-equiv="refresh" content="0;url=upload2.php" />

<?

}else{

echo " not working";

}

?>

this will not work and show message

if the name is not redarrow then work.

<?

$name="redarrow";

if($name!="redarrow"){
?>

<meta http-equiv="refresh" content="0;url=upload2.php" />

<?

}else{

echo " not working";

}

?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#38 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 20 July 2006 - 02:43 AM

I have loaded the upload.php file to my server and tried to run it and got this error.

Warning: Cannot modify header information - headers already sent by (output started at /home/forsa7/public_html/functions.php:155) in /home/forsa7/public_html/uploadform.php on line 232

I am not sure which file you used to get it to work.

#39 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 July 2006 - 02:44 AM

Yes, it works for me when I use your uploadform.php code...I just comment out the include("functions.php") and the calls to the functions that are located on it.  The switch block looks like this:

switch ($funcs[$key]) {
                                case 'LettersAndDigits':
                                        //if (!LettersAndDigits($val)) $err[] = $key;
                                        break;
                                case 'Variable':
                                        //if (!Variable($val)) $err[] = $key;
                                        break;
                                case 'Dollars':
                                        //if (!Dollars($val)) $err[] = $key;
                                        break;
                                case 'ItemCategory':
                                        //$ic = ItemCategory($val);
                                        //if (!$ic[0]) {
                                        //        $err[] = $key;
                                         //       $err_msg[$key] = $ic[1];
                                        //}
                                        break;
                                case 'isDigits':
                                        //if (!isDigits($val)) $err[] = $key;
                                        break;
                                case 'EmailorEmpty':
                                        //if (!EmailorEmpty($val)) $err[] = stripslashes($key);
                                        break;
                                case 'BidIncrement':
                                        //$bi = BidIncrement($val,$itemType[$_POST['item_type']]);
                                        //if (!$bi[0]) {
                                        //        $err[] = $key;
                                         //       $err_msg[$key] = $bi[1];
                                        //}
                                        break;
                                case 'ReservePrice':
                                        //$rp = ReservePrice($val,$itemType[$_POST['item_type']]);
                                        //if (!$rp[0]) {
                                        //        $err[] = $key;
                                         //       $err_msg[$key] = $rp[1];
                                        //}
                                        break;
                        }
but that is the only change besides removing the include statement.  Basically I'm forcing it to bypass the validation, return true, and then redirect, which works...without functions.php.

#40 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 July 2006 - 02:45 AM

That's where the problem is:

output started at /home/forsa7/public_html/functions.php:155


functions.php line 155




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users