I need help figuring out several coding issues.
Posted: Wed Dec 03, 2008 7:16 am
Hi, I am a newbie and have run into some issues with some code that I could use help understanding or correcting. I am modifing the code to fit my needs. Any and all help is appreciated and please forgive me if my syntax is not the best yet.
My before code-
And here is the html form-
The first issue with this is that the category menu doubles in the drop down box. I can't figure out why. I only need the categories to be listed once. I went ahead and moved on to my next project. Presently my vendors have to host their digital files elsewhere and just enter the url into the box to be saved until after payment when the url is returned to the customer for download. I needed a button for the vedor to upload thier digital file to be hosted on by me so I came up with this-
With my html-
This has worked as far as it lets the file be uploaded but I need the box to save the full url (domain + file location) so that when payment is made it returns the download location and not just the upload/ file path which is what it is doing now. I am not sure how to get the $newpath to show both the domain and file location automatically and save that location for future download.
I know this is a lot of code to weed through and I wasn't sure exactly how much to post so I figured more info was better. thanks inadvance for any advice you can give
My before code-
Code: Select all
<?php
include("header.php");
include("leftarea.php");
include_once ("class/category.class.php");
include_once ("class/members.class.php");
include_once ("class/product.class.php");
include_once ("member_menu.php");
$clsProduct = new Products();
$user = new Members();
$is_promember = ($user -> GetTypeofMember($_SESSION["suserid"])==1);
$fposting_fee = $is_promember?$featureposting_fee:$free_fee_feature_posting;
if(isset($_SESSION['user']))
{
$template->set_filenames(array("body" => "m_postproduct.html"));
if (isset($_GET["id"]) && $_GET["id"] != "")
{
$row = mysql_fetch_array($clsProduct->GetById($_GET["id"]));
if ( isset($row) && $row["product_member_id"] == $_SESSION["suserid"])
{
$product_cat = isset($row['subcategory'])?$row['subcategory']:"";
$product_title = isset($row['product_title'])?$row['product_title']:"";
$product_brief = isset($row['product_brief'])?$row['product_brief']:"";
$product_description = isset($row['product_description'])?$row['product_description']:"";
$product_delivery_information = isset($row['product_delivery_info'])?$row['product_delivery_info']:"";
$product_imageurl = isset($row['product_picture_url'])?$row['product_picture_url']:"";
$product_storeurl = isset($row['product_upload_url'])?$row['product_upload_url']:"";
$product_thank_you_words = isset($row['product_thankyou'])?$row['product_thankyou']:"";
$product_price = isset($row['product_price'])?$row['product_price']:"";
$product_feature = isset($row['product_feature'])?$row['product_feature']:0;
$payby_pp = isset($row['payby_pp'])?$row['payby_pp']:"";
$payby_sp = isset($row['payby_sp'])?$row['payby_sp']:"";
$was_feature_flag = (int)$row["was_feature_flag"];
}else
{
echo "<center><span class='highlight'>Data not found or you dont have right to edit data</span></center>";
//redirect("index.php");
die();
}
}else
{
$str = $user -> CheckPostingLimit($_SESSION["suserid"]);
if ($str != "")
{
echo "<p style='font-size: 13px; font-family: arial, helvetica;color:red;'>$str</p></td></tr></table>";
include("footer.php");
die;
}
}
$ok = 1;
if (isset($_POST["postproduct"]))
{
//---------------------------------------------
// Get Posting Information
//---------------------------------------------
$product_cat = isset($_POST['product_cat'])?$_POST['product_cat']:$product_cat;
$product_title = isset($_POST['product_title'])?$_POST['product_title']:$product_title;
$product_brief = isset($_POST['product_brief'])?$_POST['product_brief']:$product_brief;
$product_description = isset($_POST['product_description'])?$_POST['product_description']:$product_description;
$product_delivery_information = isset($_POST['product_delivery_information'])?$_POST['product_delivery_information']: $product_delivery_information;
if (is_uploaded_file($_FILES["product_imageurl"]["tmp_name"]))
{
if (strrpos($_FILES["product_imageurl"]["type"],"image/") === false)
{
$inform = "Warning: Invalid Image file was uploaded! Data was saved successful without updating image url.";
}else
{
$newpath = "upload/image/".time(). substr($_FILES["product_imageurl"]["name"],strrpos($_FILES["product_imageurl"]["name"],"."));
if (move_uploaded_file($_FILES["product_imageurl"]["tmp_name"], $newpath))
{
$inform = "";
$product_imageurl = $newpath;
}else
{
$inform = "Image cannot be moved for some reason, no action occur!!!";
}
}
}else
$product_imageurl = isset($_POST['product_imageurl_text'])?$_POST['product_imageurl_text']: $product_imageurl;
$product_storeurl = isset($_POST['product_downloadurl'])?$_POST['product_downloadurl']:$product_storeurl;
$product_thank_you_words = isset($_POST['product_thank_you_words'])?$_POST['product_thank_you_words']: $product_thank_you_words;
$product_price = isset($_POST['product_price'])?$_POST['product_price']:$product_price;
$payby_pp = isset($_POST['payby_pp'])?1:0;
$payby_sp = isset($_POST['payby_sp'])?1:0;
$product_feature = isset($_POST['product_feature'])?1:0;
if ($_POST['product_cat'] <= 0)
{
$cat_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz chose type of product";
$ok = 0;
}
else $cat_alert = "";
if ($_POST['product_title'] == "")
{
$title_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill product title";
$ok = 0;
}
else $title_alert = "";
if ($_POST['product_brief'] == "")
{
$brief_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill sub title";
$ok = 0;
}else
if (strlen($_POST['product_brief'])>60)
{
$brief_alert = "<img src = '".$template_dir."/images/alert.gif'> Sub title limited in maximum 60 characters";
$ok = 0;
}
else $brief_alert = "Sub title limited in maximum 60 characters";
if ($_POST['product_description'] == "")
{
$description_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill product description";
$ok = 0;
}
if ($_POST['product_downloadurl'] == "")
{
$downloadurl_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill product download url";
$ok = 0;
}
else $downloadurl_alert = "";
if ($_POST['product_delivery_information'] == "")
{
$delivery_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill delivery information";
$ok = 0;
}
else $delivery_alert = "";
if ($_POST['product_thank_you_words'] == "")
{
$thankyou_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill thank you words";
$ok = 0;
}
else $thankyou_alert = "";
if ($_POST['product_price'] == "")
{
$price_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill product price";
$ok = 0;
}
else $price_alert = "";
if ($payby_pp==0 && $payby_sp == 0)
{
$payment_alert = "<img src = '".$template_dir."/images/alert.gif'> Must choose at least one payment method";
$ok = 0;
}
else $payment_alert = "";
// Adding Product
//------------------------------------------------------
if ($ok == 1)
{
if (isset($_GET["id"]) && $_GET["id"] != "")
{
$tmp = ($product_feature == 1 && $was_feature_flag==0)?0:$product_feature;
$sid = $clsProduct->Update($_GET["id"], $product_title , $product_brief, $product_cat, $product_storeurl, $product_imageurl, $product_description, $product_delivery_information, $product_price, $product_thank_you_words, $tmp, $payby_pp , $payby_sp, $was_feature_flag);
}else
{
$was_feature_flag = 0;
$sid = $clsProduct->AddNew($product_title , $product_brief, $product_cat, $product_storeurl, $product_imageurl, $product_description, $product_delivery_information, $product_price, $product_thank_you_words, $_SESSION["suserid"], date("m/j/Y", time()), 0, $payby_pp, $payby_sp, $was_feature_flag );
}
if ($product_feature == 1 && $was_feature_flag==0)
{
$r = mysql_fetch_array($user -> GetBySId($_SESSION["suserid"]));
$balance = (double)$r["member_balance"];
$display = $balance-$featureposting_fee>$negative_member_money_bounds;
$template->set_filenames(array("confirmfeature" => "m_confirmfeature.html"));
$template->assign_vars(array(
'PRODUCT_SID' => $sid,
'PRODUCT_TITLE' => $product_title,
'FEATUREPOSTING_FEE' => $fposting_fee,
'ADMINPAYPAL_EMAIL'=> $admin_pemail,
'GETSUCCESSDATA'=> md5("pro_id")."=".$sid,
'ADMINSTORMPAY_EMAIL'=> $admin_semail,
'DISPLAY' => $display?"style='display: none;'":"",
'UN_DISPLAY' => $display?"":"style='display: none;'",
'BALANCE' => $balance
));
$template->pparse("confirmfeature");
die;
}
echo "<center><span class='highlight'>Your product was posted successfully. If your browser does not autoredirect, please click <a href='m_viewproduct.php?id=".$sid."'>here</a> to continue</span></center>";
redirect("m_viewproduct.php?id=".$sid);
}
}
$template->assign_vars(array(
'PRO_ID' => $_GET["id"],
'FORMTITLE'=> isset($_GET["id"])?"Edit product: <span class='txt_big'>".$product_title."</span>":"<span class='txt_big'>Post new product</span>",
'CAT_ALERT' => $cat_alert,
'TITLE_ALERT' => $title_alert,
'BRIEF_ALERT' => $brief_alert==""?" <span class='txt_red'>Sub title limited in maximum 60 characters</span>":$brief_alert,
'DESCRIPTION_ALERT' => $description_alert,
'DOWNLOADURL_ALERT' => $downloadurl_alert,
'DELIVERY_ALERT' => $delivery_alert,
'THANKYOU_ALERT' => $thankyou_alert,
'PRICE_ALERT' => $price_alert,
'PAYMENT_ALERT' => $payment_alert,
'PRODUCT_TITLE' => $product_title,
'PRODUCT_BRIEF' => $product_brief,
'PRODUCT_DESCRIPTION' => $product_description,
'PRODUCT_DELIVERY' => $product_delivery_information,
'DOWNLOADPROURL' => $product_storeurl,
'PRODUCTIMGURL' => $product_imageurl,
'PRODUCT_THANKYOU' => $product_thank_you_words,
'FEATURE' => ($product_feature == 1)?"<input type='checkbox' name = 'product_feature' class='normal' checked> <b>Feature Product</b> (with fee is $".$fposting_fee.")":"<input type='checkbox' name = 'product_feature' class='normal'> <b>Feature Product</b> (with fee is $".$fposting_fee.")",
'PRODUCT_PRICE' => CurrencyFormat1($product_price),
//----------------------------------------------
// Loading Category
$clsCategory=new Category();
$result = $clsCategory->GetAllCat();
while ($row = mysql_fetch_array($result))
{
$template->assign_block_vars("catselect",array(
"NAME" => $row["name"],
"VALUE" => 0
));
// load sub
$r = $clsCategory->GetAllSubCat($row["id"]);
while ($rows = mysql_fetch_array($r))
{
$template->assign_block_vars("catselect",array(
"NAME" => $rows["name"],
"VALUE" => $rows["id"],
"SELECTED" => ($product_cat == $rows["id"])?"selected":""
));
}
$template->assign_block_vars("catselect",array(
"NAME" => "-------------------------",
"VALUE" => 0
));
}
$template->pparse("body");
}
else
redirect("login.php");
include("footer.php");
php?>
Code: Select all
<html>
<head>
<title>Add Product</title>
</head>
<body>
<table style="width:100%;" border="0" cellpadding="0" cellspacing="1" background="{TEMPLATE_DIR}/images/topbg.gif">
<tr valign="top">
<td class="txt_big">{FORMTITLE}</td>
</tr>
</table>
<table style="width:100%;" border="0" cellpadding="5" cellspacing="3" background="{TEMPLATE_DIR}/images/topbg.gif">
<form action="m_postproduct.php?act=edit&id={PRO_ID}" method="post" name = "myform" enctype="multipart/form-data">
<tr valign="top">
<td align="right">Product category *</td>
<td>
<select name = 'product_cat'>
<!-- BEGIN catselect -->
<option value="{catselect.VALUE}"{catselect.SELECTED}>{catselect.NAME}</option>
<!-- END catselect -->
</select>{CAT_ALERT}
</td>
</tr>
<tr valign="top">
<td align="right">Product Title *</td>
<td><input type="text" name="product_title" size="20" value="{PRODUCT_TITLE}">{TITLE_ALERT}</td>
</tr>
<tr valign="top">
<td align="right">Sub Title *</td>
<td><input type="text" name="product_brief" size="20" value="{PRODUCT_BRIEF}">{BRIEF_ALERT}</td>
</tr>
<tr valign="top">
<td align="right">Product Description *</td>
<td>
<textarea name="product_description" cols="40" rows="8">{PRODUCT_DESCRIPTION}</textarea>{DESCRIPTION_ALERT}
</td>
</tr>
<tr valign="top">
<td align="right">Product Delivery Information *</td>
<td>
<textarea name="product_delivery_information" cols="40" rows="8">{PRODUCT_DELIVERY}</textarea>{DELIVERY_ALERT}
</td>
</tr>
<tr valign="top">
<td align="right">Product Download Url</td>
<td><input name="product_downloadurl" size="30" type="text" value="{DOWNLOADPROURL}">{DOWNLOADURL_ALERT}</td>
</tr>
<tr valign="top">
<td align="right">Product PDF OR ZIP File</td>
<td><input name="product_downloadurl" size="30" type="file" value="{DOWNLOADPROURL}"></td>
</tr>
<tr valign="top">
<td align="right">Product Image Url</td>
<td><input name="product_imageurl_text" size="30" type="text" value="{PRODUCTIMGURL}"></td>
</tr>
<tr valign="top">
<td align="right">Product Image</td>
<td><input name="product_imageurl" size="30" type="file"></td>
</tr>
<tr valign="top">
<td align="right">Thank you words *</td>
<td>
<textarea name="product_thank_you_words" cols="40" rows="4">{PRODUCT_THANKYOU}</textarea>{THANKYOU_ALERT}
</td>
</tr>
</body>
</html>
Code: Select all
<?php
include("header.php");
include("leftarea.php");
include_once ("class/category.class.php");
include_once ("class/members.class.php");
include_once ("class/product.class.php");
include_once ("member_menu.php");
$clsProduct = new Products();
$user = new Members();
$is_promember = ($user -> GetTypeofMember($_SESSION["suserid"])==1);
$fposting_fee = $is_promember?$featureposting_fee:$free_fee_feature_posting;
if(isset($_SESSION['user']))
{
$template->set_filenames(array("body" => "m_postproduct.html"));
if (isset($_GET["id"]) && $_GET["id"] != "")
{
$row = mysql_fetch_array($clsProduct->GetById($_GET["id"]));
if ( isset($row) && $row["product_member_id"] == $_SESSION["suserid"])
{
$product_cat = isset($row['subcategory'])?$row['subcategory']:"";
$product_title = isset($row['product_title'])?$row['product_title']:"";
$product_brief = isset($row['product_brief'])?$row['product_brief']:"";
$product_description = isset($row['product_description'])?$row['product_description']:"";
$product_delivery_information = isset($row['product_delivery_info'])?$row['product_delivery_info']:"";
$product_imageurl = isset($row['product_picture_url'])?$row['product_picture_url']:"";
$product_storeurl = isset($row['product_upload_url'])?$row['product_upload_url']:"";
$product_thank_you_words = isset($row['product_thankyou'])?$row['product_thankyou']:"";
$product_price = isset($row['product_price'])?$row['product_price']:"";
$product_feature = isset($row['product_feature'])?$row['product_feature']:0;
$payby_pp = isset($row['payby_pp'])?$row['payby_pp']:"";
$payby_sp = isset($row['payby_sp'])?$row['payby_sp']:"";
$was_feature_flag = (int)$row["was_feature_flag"];
}else
{
echo "<center><span class='highlight'>Data not found or you dont have right to edit data</span></center>";
die();
}
}else
{
$str = $user -> CheckPostingLimit($_SESSION["suserid"]);
if ($str != "")
{
echo "<p style='font-size: 13px; font-family: arial, helvetica;color:red;'>$str</p></td></tr></table>";
include("footer.php");
die;
}
}
$ok = 1;
if (isset($_POST["postproduct"]))
{
//---------------------------------------------
// Get Posting Information
//---------------------------------------------
$product_cat = isset($_POST['product_cat'])?$_POST['product_cat']:$product_cat;
$product_title = isset($_POST['product_title'])?$_POST['product_title']:$product_title;
$product_brief = isset($_POST['product_brief'])?$_POST['product_brief']:$product_brief;
$product_description = isset($_POST['product_description'])?$_POST['product_description']:$product_description;
$product_delivery_information = isset($_POST['product_delivery_information'])?$_POST['product_delivery_information']: $product_delivery_information;
//Uploading Pic
if (is_uploaded_file($_FILES["product_imageurl"]["tmp_name"]))
{
if (strrpos($_FILES["product_imageurl"]["type"],"image/") === false)
{
$inform = "Warning: Invalid Image file was uploaded! Data was saved successful without updating image url.";
}else
{
$newpath = "upload/image/".time(). substr($_FILES["product_imageurl"]["name"],strrpos($_FILES["product_imageurl"]["name"],"."));
if (move_uploaded_file($_FILES["product_imageurl"]["tmp_name"], $newpath))
{
$inform = "Image Uploaded";
$product_imageurl = $newpath;
}else
{
$inform = "Image cannot be moved for some reason, no action occured!!!";
}
}
}else
$product_imageurl = isset($_POST['product_imageurl_text'])?$_POST['product_imageurl_text']: $product_imageurl;
//End Pic Upload
// Added New Uploading File Area
if (is_uploaded_file($_FILES["product_downloadurl"]["tmp_name"]))
{
if (strrpos($_FILES["product_downloadurl"]["type"],"file/") === false)
{
$inform = "Warning: Invalid file type was uploaded! Data was saved successfully without updating your product download file.";
}else
{
$newpath = "upload/file/".time(). substr($_FILES["product_downloadurl"]["name"],strrpos($_FILES["product_downloadurl"]["name"],"."));
if (move_uploaded_file($_FILES["product_downloadurl"]["tmp_name"], $newpath))
{
$inform = "";
$product_storeurl = $newpath;
}else
{
$inform = "File cannot be moved for some reason, no action occured!!!";
}
}
}else
$product_storeurl = isset($_POST['product_downloadurl_text'])?$_POST['product_downloadurl_text']: $product_storeurl;
//End of new File Upload area
$product_thank_you_words = isset($_POST['product_thank_you_words'])?$_POST['product_thank_you_words']: $product_thank_you_words;
$product_price = isset($_POST['product_price'])?$_POST['product_price']:$product_price;
$payby_pp = isset($_POST['payby_pp'])?1:0;
$payby_sp = isset($_POST['payby_sp'])?1:0;
$product_feature = isset($_POST['product_feature'])?1:0;
if ($_POST['product_cat'] <= 0)
{
$cat_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz chose type of product";
$ok = 0;
}
else $cat_alert = "";
if ($_POST['product_title'] == "")
{
$title_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill product title";
$ok = 0;
}
else $title_alert = "";
if ($_POST['product_brief'] == "")
{
$brief_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill sub title";
$ok = 0;
}else
if (strlen($_POST['product_brief'])>60)
{
$brief_alert = "<img src = '".$template_dir."/images/alert.gif'> Sub title limited in maximum 60 characters";
$ok = 0;
}
else $brief_alert = "Sub title limited in maximum 60 characters";
if ($_POST['product_description'] == "")
{
$description_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill product description";
$ok = 0;
}
if ($_POST['product_downloadurl'] == "")
{
$downloadurl_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill product download url";
$ok = 0;
}
else $downloadurl_alert = "";
if ($_POST['product_delivery_information'] == "")
{
$delivery_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill delivery information";
$ok = 0;
}
else $delivery_alert = "";
if ($_POST['product_thank_you_words'] == "")
{
$thankyou_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill thank you words";
$ok = 0;
}
else $thankyou_alert = "";
if ($_POST['product_price'] == "")
{
$price_alert = "<img src = '".$template_dir."/images/alert.gif'> Plz fill product price";
$ok = 0;
}
else $price_alert = "";
if ($payby_pp==0 && $payby_sp == 0)
{
$payment_alert = "<img src = '".$template_dir."/images/alert.gif'> Must choose at least one payment method";
$ok = 0;
}
else $payment_alert = "";
// Adding Product
//------------------------------------------------------
if ($ok == 1)
{
if (isset($_GET["id"]) && $_GET["id"] != "")
{
$tmp = ($product_feature == 1 && $was_feature_flag==0)?0:$product_feature;
$sid = $clsProduct->Update($_GET["id"], $product_title , $product_brief, $product_cat, $product_storeurl, $product_imageurl, $product_description, $product_delivery_information, $product_price, $product_thank_you_words, $tmp, $payby_pp , $payby_sp, $was_feature_flag);
}else
{
$was_feature_flag = 0;
$sid = $clsProduct->AddNew($product_title , $product_brief, $product_cat, $product_storeurl, $product_imageurl, $product_description, $product_delivery_information, $product_price, $product_thank_you_words, $_SESSION["suserid"], date("m/j/Y", time()), 0, $payby_pp, $payby_sp, $was_feature_flag );
}
if ($product_feature == 1 && $was_feature_flag==0) //Must be pay extra money for feature product
{
$r = mysql_fetch_array($user -> GetBySId($_SESSION["suserid"]));
$balance = (double)$r["member_balance"];
$display = $balance-$featureposting_fee>$negative_member_money_bounds;
$template->set_filenames(array("confirmfeature" => "m_confirmfeature.html"));
$template->assign_vars(array(
'PRODUCT_SID' => $sid,
'PRODUCT_TITLE' => $product_title,
'FEATUREPOSTING_FEE' => $fposting_fee,
'ADMINPAYPAL_EMAIL'=> $admin_pemail,
'GETSUCCESSDATA'=> md5("pro_id")."=".$sid,
'ADMINSTORMPAY_EMAIL'=> $admin_semail,
'DISPLAY' => $display?"style='display: none;'":"",
'UN_DISPLAY' => $display?"":"style='display: none;'",
'BALANCE' => $balance
));
$template->pparse("confirmfeature");
die;
}
echo "<center><span class='highlight'>Your product was posted successfully. If your browser does not autoredirect, please click <a href='m_viewproduct.php?id=".$sid."'>here</a> to continue</span></center>";
redirect("m_viewproduct.php?id=".$sid);
}
}
$template->assign_vars(array(
'PRO_ID' => $_GET["id"],
'FORMTITLE'=> isset($_GET["id"])?"Edit product: <span class='txt_big'>".$product_title."</span>":"<span class='txt_big'>Post new product</span>",
'CAT_ALERT' => $cat_alert,
'TITLE_ALERT' => $title_alert,
'BRIEF_ALERT' => $brief_alert==""?" <span class='txt_red'>Sub title limited in maximum 60 characters</span>":$brief_alert,
'DESCRIPTION_ALERT' => $description_alert,
'DOWNLOADURL_ALERT' => $downloadurl_alert,
'DELIVERY_ALERT' => $delivery_alert,
'THANKYOU_ALERT' => $thankyou_alert,
'PRICE_ALERT' => $price_alert,
'PAYMENT_ALERT' => $payment_alert,
'PRODUCT_TITLE' => $product_title,
'PRODUCT_BRIEF' => $product_brief,
'PRODUCT_DESCRIPTION' => $product_description,
'PRODUCT_DELIVERY' => $product_delivery_information,
'DOWNLOADPROURL' => $product_storeurl,
'PRODUCTIMGURL' => $product_imageurl,
'PRODUCT_THANKYOU' => $product_thank_you_words,
'FEATURE' => ($product_feature == 1)?"<input type='checkbox' name = 'product_feature' class='normal' checked> <b>Feature Product</b> (with fee is $".$fposting_fee.")":"<input type='checkbox' name = 'product_feature' class='normal'> <b>Feature Product</b> (with fee is $".$fposting_fee.")",
'PRODUCT_PRICE' => CurrencyFormat1($product_price),
'PAYBYPAYPAL' => $payby_pp==1?"checked":""
));
//----------------------------------------------
// Loading Category
$clsCategory=new Category();
$result = $clsCategory->GetAllCat();
while ($row = mysql_fetch_array($result))
{
$template->assign_block_vars("catselect",array(
"NAME" => $row["name"],
"VALUE" => 0
));
// load sub
$r = $clsCategory->GetAllSubCat($row["id"]);
while ($rows = mysql_fetch_array($r))
{
$template->assign_block_vars("catselect",array(
"NAME" => $rows["name"],
"VALUE" => $rows["id"],
"SELECTED" => ($product_cat == $rows["id"])?"selected":""
));
}
$template->assign_block_vars("catselect",array(
"NAME" => "-------------------------",
"VALUE" => 0
));
}
$template->pparse("body");
}
else
redirect("login.php");
include("footer.php");
php?>
Code: Select all
<html>
<head>
<title>Add Product</title>
</head>
<body>
<table style="width:100%;" border="0" cellpadding="0" cellspacing="1" background="{TEMPLATE_DIR}/images/topbg.gif">
<tr valign="top">
<td class="txt_big">{FORMTITLE}</td>
</tr>
</table>
<table style="width:100%;" border="0" cellpadding="5" cellspacing="3" background="{TEMPLATE_DIR}/images/topbg.gif">
<form action="m_postproduct.php?act=edit&id={PRO_ID}" method="post" name = "myform" enctype="multipart/form-data">
<tr valign="top">
<td align="right">Product category *</td>
<td>
<select name = 'product_cat'>
<!-- BEGIN catselect -->
<option value="{catselect.VALUE}"{catselect.SELECTED}>{catselect.NAME}</option>
<!-- END catselect -->
</select>{CAT_ALERT}
</td>
</tr>
<tr valign="top">
<td align="right">Product Title *</td>
<td><input type="text" name="product_title" size="20" value="{PRODUCT_TITLE}">{TITLE_ALERT}</td>
</tr>
<tr valign="top">
<td align="right">Sub Title *</td>
<td><input type="text" name="product_brief" size="20" value="{PRODUCT_BRIEF}">{BRIEF_ALERT}</td>
</tr>
<tr valign="top">
<td align="right">Product Description *</td>
<td>
<textarea name="product_description" cols="40" rows="8">{PRODUCT_DESCRIPTION}</textarea>{DESCRIPTION_ALERT}
</td>
</tr>
<tr valign="top">
<td align="right">Product Delivery Information *</td>
<td>
<textarea name="product_delivery_information" cols="40" rows="8">{PRODUCT_DELIVERY}</textarea>{DELIVERY_ALERT}
</td>
</tr>
<tr valign="top">
<td align="right">Product Download Url</td>
<td><input name="product_downloadurl" size="30" type="text" value="{DOWNLOADPROURL}">{DOWNLOADURL_ALERT}</td>
</tr>
<tr valign="top">
<td align="right">Product PDF OR ZIP File</td>
<td><input name="product_downloadurl" size="30" type="file" value="{DOWNLOADPROURL}"></td>
</tr>
<tr valign="top">
<td align="right">Digital File Upload</td>
<td><input name="product_downloadurl" size="30" type="file" value="{DOWNLOADPROURL}"></td>
</tr>
<tr valign="top">
<td align="right">Product Image Url</td>
<td><input name="product_imageurl_text" size="30" type="text" value="{PRODUCTIMGURL}"></td>
</tr>
<tr valign="top">
<td align="right">Product Image</td>
<td><input name="product_imageurl" size="30" type="file"></td>
</tr>
<tr valign="top">
<td align="right">Thank you words *</td>
<td>
<textarea name="product_thank_you_words" cols="40" rows="4">{PRODUCT_THANKYOU}</textarea>{THANKYOU_ALERT}
</td>
</tr>
</body>
</html>
I know this is a lot of code to weed through and I wasn't sure exactly how much to post so I figured more info was better. thanks inadvance for any advice you can give