...

View Full Version : Can Someone Please Clarify.....



Byronwells
01-28-2010, 02:41 AM
Alright guys

I am very much interested to know what these two peices of code does please..

Please find enclosed the full code for the add product section of the membership script.



<?php

include "session.php" ;
include "header.php" ;

$GetFile = file("../html/admin/add_product.html");
$Content = join("", $GetFile);

function encodeHTML($sHTML)
{
$sHTML=ereg_replace("&","&amp;",$sHTML);
$sHTML=ereg_replace("<","&lt;",$sHTML);
$sHTML=ereg_replace(">","&gt;",$sHTML);
return $sHTML;
}

if (isset($_POST['submit']))
{
// Clean up form data
$product_name = addslashes($_POST["product_name"]);
$pshort = $_POST["pshort"];
$price = $_POST["price"];
$commission = $_POST["commission"];
$jv_commission = $_POST["jv_commission"];
$index_page = addslashes($_POST["index_page"]);
$download_form = addslashes($_POST["download_form"]);
$price_increase = $_POST["price_increase"];
$increase = $_POST["increase"];
$price_interval = $_POST["price_interval"];
$increase_finish = $_POST["increase_finish"];
$home_page_product = $_POST["home_page_product"];
$use_headers = $_POST["use_headers"];
$limit_members = $_POST["limit_members"];
$reset = $_POST["reset"];
$member_cap = $_POST["member_cap"];
$membershipcap = addslashes($_POST["membershipcap"]);
$points_on = $_POST["points_on"];
$points_req = $_POST["points_req"];
$pp_button = $_POST["pp_button"];
$pptext = addslashes($_POST["pptext"]);
$ppbutton = addslashes($_POST["ppbutton"]);
$show_product = $_POST["show_product"];
$get_affurl = $_POST["get_affurl"];
$subscription_active = $_POST["subscription_active"];
$period1_active = $_POST["period1_active"];
$period1_value = $_POST["period1_value"];
$period1_interval = $_POST["period1_interval"];
$srt = $_POST["srt"];
$amount1 = $_POST["amount1"];
$period2_active = $_POST["period2_active"];
$period2_value = $_POST["period2_value"];
$period2_interval = $_POST["period2_interval"];
$amount2 = $_POST["amount2"];
$period3_value = $_POST["period3_value"];
$period3_interval = $_POST["period3_interval"];
$psponder = $_POST["psponder"];
$category = $_POST["category"];
$tcontent = $_POST["tcontent"];
$amount3 = $_POST["amount3"];
$dl_loc = $_POST["dl_loc"];
$offsite = addslashes($_POST["offsite"]);
$imageurl = $_POST["imageurl"];
$prod_description = addslashes($_POST["prod_description"]);

if ($home_page_product=='1')
{
$set = "home_page_product = '0'";
$db->insert("update ".$prefix."products set $set");
$home_page_product = "1";
}

$set = "product_name = '$product_name',";
$set .= "pshort ='$pshort',";
$set .= "price = '$price',";
$set .= "commission = '$commission',";
$set .= "jv_commission = '$jv_commission',";
$set .= "index_page = '$index_page',";
$set .= "download_form = '$download_form',";
$set .= "price_increase = '$price_increase',";
$set .= "increase = '$increase',";
$set .= "price_interval = '$price_interval',";
$set .= "increase_finish = '$increase_finish',";
$set .= "home_page_product = '$home_page_product'," ;
$set .= "use_headers ='$use_headers',";
$set .= "main_product ='$main_product',";
$set .= "limit_members ='$limit_members',";
$set .= "reset ='$reset',";
$set .= "member_cap = '$member_cap',";
$set .= "membershipcap = '$membershipcap',";
$set .= "points_on ='$points_on',";
$set .= "points_req ='$points_req',";
$set .= "pp_button ='$pp_button',";
$set .= "pptext = '$pptext',";
$set .= "ppbutton = '$ppbutton',";
$set .= "show_product ='$show_product',";
$set .= "get_affurl ='$get_affurl',";
$set .= "subscription_active = '$subscription_active',";
$set .= "period1_active = '$period1_active',";
$set .= "period1_value = '$period1_value',";
$set .= "period1_interval = '$period1_interval',";
$set .= "srt = '$srt',";
$set .= "amount1 = '$amount1',";
$set .= "period2_active = '$period2_active',";
$set .= "period2_value = '$period2_value',";
$set .= "period2_interval = '$period2_interval',";
$set .= "amount2 = '$amount2',";
$set .= "period3_value = '$period3_value',";
$set .= "period3_interval = '$period3_interval',";
$set .= "amount3 = '$amount3',";
$set .= "psponder = '$psponder',";
$set .= "tcontent = '$tcontent',";
$set .= "dl_loc = '$dl_loc',";
$set .= "imageurl = '$imageurl',";
$set .= "prod_description = '$prod_description',";
$set .= "category = '$category',";
$set .= "offsite = '$offsite'";


$pid = $db->insert_data_id("insert into ".$prefix."products set $set") ;
$msg = "add";
header("Location: paid_products.php?msg=$msg");
}

$q = "select * from ".$prefix."category order by cat_name";
$r = $db->get_rsltset($q);
for ($i=0; $i < count($r); $i++)
{
@extract($r[$i]);
$pid = $cat_name;

if($pid ==$showcat)
{
$category.="<option value='$pid' Selected>$pid</option>";
}
elseif($pid !=$showcat)
{
$category.="<option value='$pid'>$pid</option>";
}
}


$q = "select * from ".$prefix."responders order by rspname2";
$r = $db->get_rsltset($q);

for ($i=0; $i < count($r); $i++)
{
@extract($r[$i]);
$pid = $rspname2;

if($pid ==$showpaid)
{
$psponder.="<option value='$pid' Selected>$pid</option>";
}
elseif($pid !=$showpaid)
{
$psponder.="<option value='$pid'>$pid</option>";
}
}
$q = "select * from ".$prefix."tccampaign order by shortname";
$r = $db->get_rsltset($q);
for ($i=0; $i < count($r); $i++)
{
@extract($r[$i]);
$pid = $shortname;

if($pid ==$showtimed)
{
$tcontent.="<option value='$pid' Selected>$pid</option>";
}
elseif($pid !=$showtimed)
{
$tcontent.="<option value='$pid'>$pid</option>";
}
}


$Content = preg_replace($Ptn,"$$1",$Content);
echo $Content;

include "footer.php";
?>


The two snippets of code that I am interested in are as follows



if (isset($_POST['submit']))
{
// Clean up form data
$product_name = addslashes($_POST["product_name"]);
$pshort = $_POST["pshort"];
$price = $_POST["price"];




$set = "product_name = '$product_name',";
$set .= "pshort ='$pshort',";


Does those two bits of the code tell the script to access the database and display in in the right field... Then allow me to display the information that is stored in that field on a different page using a keyword?

Basically I am trying to find out how to tell a new drop down menu that I have created which has got four licences in it, see here http://www.digitalresellersvault.com/template/add_product.html to be stored in a field on the database called licence

bdl
01-28-2010, 03:08 AM
Those two code snippets you've posted do this, respectively: take POST REQUEST data and reassign it to new variables, sporadically using addslashes along the way (BAD idea, by the way), and create an SQL fragment to be used in a larger INSERT query using that same input data.

It does not output any data. You could certainly create a SELECT element using data from the database, from any source.

Byronwells
01-28-2010, 03:30 AM
Those two code snippets you've posted do this, respectively: take POST REQUEST data and reassign it to new variables, sporadically using addslashes along the way (BAD idea, by the way), and create an SQL fragment to be used in a larger INSERT query using that same input data.

It does not output any data. You could certainly create a SELECT element using data from the database, from any source.

Ok how do I go about making the licence drop down menu information be stored in the licence field of the database??



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum