Location: PHPKode > projects > PHP Gateway > e-comm/catalog/3.php
<style type="text/css">

.link
{
  color: steelblue;
  text-decoration: underline;
  cursor: pointer;
  cursor: hand;
  font-family:arial;
  font-size:14px;
}

</style>


<?
require("../inf.php");
mysql_connect("$host", "$user", "$pass	");
mysql_select_db("sportplus");

$result = mysql_query("SELECT * FROM product WHERE prodcode = '".$_POST[prodcode]."'");

if($row = mysql_fetch_array($result))
{
	do
	{
		$msg = "<br><font color=red>The product ID you have chosen is already in use. You Product ID has been changed to:<br>".$_POST[prodcode]."_1</font>";
		$_POST[prodcode] = $_POST[prodcode]."_1";

	}while($row = mysql_fetch_array($result));
}

if(!$_POST[prodcode])
{
	$flag = 1;
	print("<font color=red>Please go <a href=javascript:history.back()>Back</a> And enter a product code.</font><br>");
}
if(!$_POST[prodname])
{
	$flag = 1;
	print("<font color=red>Please go <a href=javascript:history.back()>Back</a> And enter a product name.</font><br>");
}
if(!$_POST[productprice])
{
	$flag = 1;
	print("<font color=red>Please go <a href=javascript:history.back()>Back</a> And enter a Price for your product..</font><br>");
}
if(!$_POST[longdesc])
{
	$flag = 1;
	print("<font color=red>Please go <a href=javascript:history.back()>Back</a> And enter a Long Description.</font><br>");
}
if(!$_POST[shortdesc])
{
	$flag = 1;
	print("<font color=red>Please go <a href=javascript:history.back()>Back</a> And enter a Short Description.</font><br>");
}
if(!$_POST[cost])
{
	$flag = 1;
	print("<font color=red>Please go <a href=javascript:history.back()>Back</a> And enter the cost of your product.</font><br>");
}
if($flag)
{
	exit();
}



print "<center>";
print "<b><big>Product Wizard</b></big>";
print "<br><b>Variations:</b><br>On this page you will be able to upload color variations of your product. You have the option to upload up to 36 variations.";
print $msg;
?>

<?php
  $uploadDir    = "ColorVariations/";        // upload dir
  $numOfUploads = '36';         // number of files to upload
  $maxFileSize  = '500000';    // maximum file size in bytes
?>

  <?php echo '<?xml version="1.0" encoding="iso-8859-1"?>';?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <html>
  <head><title>Upload Image</title></head>
  <body bgcolor="#ffffff">
  <h5>Please Choose a File and click Submit</h5>
  <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
  <input type="hidden" name="MAX_FILE_SIZE" value="10000000">
  <?php
  $num = '0';
  while($num < $numOfUploads)
    {
        echo '<div><input name="userfile[]" type="file"></div>';
        $num++;
        }

	print("<input type=hidden name=pricat value='".$_POST[pricat]."'>");
	print("<input type=hidden name=subcat value='".$_POST[subcat]."'>");
	print("<input type=hidden name=brand value='".$_POST[brand]."'>");
	print("<input type=hidden name=cost value='".$_POST[cost]."'>");
	print("<input type=hidden name=thumb value='".$_POST[thumb]."'>");
	print("<input type=hidden name=full value='".$_POST[full]."'>");
	print("<input type=hidden name=sport value='".$_POST[sport]."'>");
	print("<input type=hidden name=prodname value='".$_POST[prodname]."'>");
	print("<input type=hidden name=prodcode value='".$_POST[prodcode]."'>");
	print("<input type=hidden name=shortdesc value='".$_POST[shortdesc]."'>");
	print("<input type=hidden name=longdesc value='".$_POST[longdesc]."'>");
	print("<input type=hidden name=productprice value='".$_POST[productprice]."'>");
	print("<input type=hidden name=chargeshipping value='".$_POST[chargeshipping]."'>");

  ?>
  <input type="submit" value="Submit">
  </form>

</body></html>

<?php
  // check if a file has been submitted
  if(!isset($_FILES['userfile']['tmp_name']))
        {
        echo '<div>No files uploaded</div>';
        }
  else
    {
    // upload the files...
    upload($maxFileSize, $uploadDir);
    }
function upload($maxFileSize, $uploadDir){
  $i=0;
  // loop through the array
  for($i=0; $i < count($_FILES['userfile']['tmp_name']);$i++)
  // check if there is a file in the array
  if(is_uploaded_file($_FILES['userfile']['tmp_name'][$i]))
    {
    // check the file is less than the maximum file size
    if($_FILES['userfile']['size'][$i] < $maxFileSize)
        {
        // copy the file to the specified dir
        if(@copy($_FILES['userfile']['tmp_name'][$i],$uploadDir.'/'.$_FILES['userfile']['name'][$i]))
            {
            // give praise and thanks to the php god
            $trigger = w00t;
            rename("ColorVariations/".$_FILES['userfile']['name'][$i], "ColorVariations/".$_POST[prodcode]."-".$_FILES['userfile']['name'][$i]);
            echo'<br><font color=red>Upload of file '.$_FILES['userfile']['name'][$i].' successful.</font>';
            }
        else
            {
            // print an error message
            echo '<div>Upload of file '.$_FILES['userfile']['name'][$i].' Failed.</div>';
            }
        }
    else
        {
        // if the file is not less than the maximum allowed, print an error
        echo
        '<div>File exceeds the Maximum File limit</div>
        <div>Maximum File limit is '.$maxFileSize.'</div>
        <div>File '.$_FILES['userfile']['name'][$i].' is '.$_FILES['userfile']['size'][$i].' bytes</div>
        <hr />';
        }
    }
}
	$ha = implode("|", $_FILES['userfile']['name']);
	print("<form action=sizes.php method=post>");
	print("<input type=hidden name=colorvar value='$ha'>");
	print("<input type=hidden name=pricat value='".$_POST[pricat]."'>");
	print("<input type=hidden name=subcat value='".$_POST[subcat]."'>");
	print("<input type=hidden name=brand value='".$_POST[brand]."'>");
	print("<input type=hidden name=thumb value='".$_POST[thumb]."'>");
	print("<input type=hidden name=full value='".$_POST[full]."'>");
	print("<input type=hidden name=cost value='".$_POST[cost]."'>");
	print("<input type=hidden name=prodname value='".$_POST[prodname]."'>");
	print("<input type=hidden name=prodcode value='".$_POST[prodcode]."'>");
	print("<input type=hidden name=shortdesc value='".$_POST[shortdesc]."'>");
	print("<input type=hidden name=sport value='".$_POST[sport]."'>");
	print("<input type=hidden name=longdesc value='".$_POST[longdesc]."'>");
	print("<input type=hidden name=productprice value='".$_POST[productprice]."'>");
	print("<input type=hidden name=chargeshipping value='".$_POST[chargeshipping]."'>");

	print("<input type=submit value='Continue'><br><small><b>!*</b> Note: You may want to upload an image first before continuing. <b>*!</b></small>");
	print("</form>");
?>


Return current item: PHP Gateway