Jump to content

Recommended Posts

I have a form that takes in a .gif image file, and I can stop it taking in junk files and anything bigger than the max size, but it always seems to allow .gif images that are bigger in dimension than is required, I have validation in place but it doesn't seem to stop it. The values of $height and $width do not seem to be set correctly.

 

<?php
  include "connect_details.php";

  $Submit = $_POST['SubmitB'];
  $ColourName = $_POST['ColourName'];
  $ColourImage = $_FILES['ColourImage']['name'];
  $Max_Size = 10240;
  $Imagetype = $_FILES['ColourImage']['type'];
  $Imagesize = $_FILES['ColourImage']['size'];
  $image_temp = $_Files['ColourImage']['tmp_name'];
  $Img_Dimensions = getimagesize($image_temp);
  $width = $Img_Dimensions[0];
  $height = $Img_Dimensions[1];
  
  echo $Imagesize;
  echo"<br>";
  echo $Imagetype;
  echo"<br>";
  echo $width;
  echo"<br>";
  echo $height;
  echo"<br>";

  $dirupload = "../images/colours/";
  $NotExec = true;

  if ($_POST['SubmitB'] == "Submit")
  {
     $errors=0;
     $Valid_ColourName = true;
     $Valid_ColourImage = true;

     echo"1<br>";

     if (empty($ColourName))
     {
        ?>

        <div style="position:absolute; top:20px; left:200px; width:550px">   
          <span class="errmsg">Please Enter a Colour Name</span>
</div>

        <?php   
        $errors++;
        $Valid_ColourName = false;

        echo"2<br>";

     }

     if (($Imagetype == "image/gif") && ($Imagesize < $Max_Size) && ($width <= 25) && ($height <=25))
     {
       if (file_exists($dirupload . $ColourImage."gif"))
       {
          ?>
          <div style="position:absolute; top:40px; left:200px; width:550px">   
             <span class="errmsg">That file already exists!</span>
   </div>
          <?php
          $Valid_ColourImage = false;
          $errors++;
       }

     }
     else
     {
        $Valid_ColourImage = false;
        $errors++;
        ?>
        <div style="position:absolute; top:40px; left:200px; width:550px">   
           <span class="errmsg">Please Select a .gif image file that is no more than 25x25 pixels in size, and is less than 10kb</span>
</div>
        <?php
        echo "3a<br>";
     }
     
     if($errors==0)
     {
        $move_image = move_uploaded_file($ColourImage['tmp_name'], $dirupload.$ColourName.".gif");
        $Valid_ColourImage = true;
        echo"3IV<br>";
     }
     else
     {
        $Valid_ColourImage = false;
        $errors++;

        echo"3d<br>";
        ?>
        <div style="position:absolute; top:40px; left:200px; width:550px">   
           <span class="errmsg">Image could not be uploaded!</span>
        </div>
        <?php
     }

     if($errors ==0)
     { 
        
        $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error());

        //Select the MySQL database

        $db = mysql_select_db($Dbname, $conn);

        $sqlNew = "INSERT INTO Colours (AvailableColours) VALUES('$ColourName')";

        $rsNew = mysql_query($sqlNew,$conn)or die('Problem with query: ' . $sqlNew . '<br />' . mysql_error());		

        if(mysql_affected_rows($conn) == "1")
        {
           $Added = true;
           $NotExec = false;
}
        elseif(mysql_affected_rows($conn) =="0")
        {
           $Added = false;
           $NotExec = true;
        ?>
           <div style="position:absolute; top:20px; left:200px; width:550px">   
           <span class="errmsg">Could not be added, <?php echo "$ColourName";?> may already exist!</span>
           </div>
        <?php
        
        }
        mysql_close($conn);
     }
   }

?>

<html>
<head>
   <title>New Product Colour Form</title>
   <link href="stylesheetCL.css" rel="stylesheet">
   <?php require('jscript.inc') ?>
   
   <?php if($NotExec == false && $Added == true)
   {
   ?>
..redirect feature goes here once complete..      
   <?php
   }
   ?>
</head>
<body>


<?php require('menu.inc') ?>

<div style="position:absolute; top:75px; left:200px; width:550px">

<span class="head3">New Product Colour Form</span>
<br>
<br>


<form method="post" enctype="multipart/form-data" action='add_product_colour_form.php'/>

<?php
if($_POST['SubmitB'] == "Submit")
{
    if($Valid_ColourName == false)
    {   
       ?>
       <span class="errmsg">! </span>
       <?php
    }

    ?>

    Colour Name: 
    <br>
    <input type="text" name="ColourName" value="<?php echo $_POST['ColourName']?>"/>

    <br>
    <br>
    
    <?php
    if($Valid_ColourImage == false)
    {
       ?>
       <span class="errmsg>"! </span>
       <?php
    }
    ?>

    Colour Image (Must be .gif image type, 25x25 pixels in dimensions and less than 10Kb in size)
    <br>
    <input type="file" name="ColourImage" value="<?php echo $_FILES['ColourImage']?>"/>

    <br>
    <br>  
<?php
}
elseif($_POST['SubmitB'] != "Submit")
{
    ?>
    Colour Name: 
    <br>
    <input type="text" name="ColourName" value=""/>
    <br>
    <br>
    Colour Image (Must be .gif image type, 25x25 pixels in dimensions and less than 10Kb in size)
    <br>
    <input type="file" name="ColourImage">
    <?php    
}   
?>

<br>
<input type="submit" name="SubmitB" value="Submit"/>
</form>  

<br>
<br>
<br>
<br>
<a href="admin.php">Back to the Admin Menu</a>

</div>

</body>
</html>

 

The current outputs for uploading just a file and not entering anything into the text field is:

 

1169 (This is an example .gif image filesize)

image/gif

(This is where $width is supposed to go)

(This is where $height is supposed to go)

1

Please Enter a Colour Name

2

3d

Image could not be uploaded!

Home

Products

 

Link to comment
https://forums.phpfreaks.com/topic/86854-solved-image-upload-dimensions-problem/
Share on other sites

This is the other form that contains the .jpeg file upload and it is doing exactly the same thing as the .gif upload

 

<?php

include "connect_details.php";

$CBSizes = array("XS","Small", "Medium", "Large", "XL", "XXL", "3XL");
$Submit = $_POST['SubmitB'];
$errors=0;

if($_POST['SubmitB'] =="Submit")
{
   $ClothingCode = $_POST['ClothingCode'];

   $Description = $_POST['Description'];

   $ItemType = $_POST['ItemType'];

   $Price1 = $_POST['Price1'];
  
   $Price2 = $_POST['Price2'];

   $NUSPrice1 = $_POST['NUSPrice1'];
  
   $NUSPrice2 = $_POST['NUSPrice2'];

   $ProductImage = $_FILES['ProductImage']['name'];
   $Max_Size = 51200;
   $Imagetype = $_FILES['ProductImage']['type'];
   $Imagesize = $_FILES['ProductImage']['size'];
   $image_temp = $_Files['ProductImage']['tmp_name'];
   $Img_Dimensions = getimagesize($image_temp);
   $width = $Img_Dimensions[0];
   $height = $Img_Dimensions[1];
  
   echo $Imagesize;
   echo"<br>";
   echo $Imagetype;
   echo"<br>";
   echo $width;
   echo"<br>";
   echo $height;
   echo"<br>";

   $dirupload = "../images/products/";
   $NotExec = true;

   $AColours = $_POST['Colours'];

   $ASizes = $_POST['Sizes'];
   
   //ClothingCode Validation

   if(empty($ClothingCode))
   {
      ?>
      <div style="position:absolute; top:10px; left:200px; width:550px">   
        <span class="errmsg">Please Enter the Clothing Code</span>
      </div>
      <?php     
      $errors++;
      $Valid_ClothingCode = false;
   }


   //Description Validation

   if(empty($Description))
   {
      ?>
      <div style="position:absolute; top:25px; left:200px; width:550px">   
        <span class="errmsg">Please Enter the Description</span>
      </div>
      <?php     
      $errors++;
      $Valid_Description = false;
   }

   //Item Type Validation
   
   if(empty($ItemType))
   {
      ?>
      <div style="position:absolute; top:40px; left:200px; width:550px">   
        <span class="errmsg">Please Select an Item Type!</span>
      </div>
      <?php
      $Valid_ItemType = false;
      $errors++;
   }

   //Price Validation

   if((empty($Price1)) || empty($Price2))
   {
      ?>
      <div style="position:absolute; top:55px; left:200px; width:550px">   
        <span class="errmsg">Please Enter the Price</span>
      </div>
      <?php     
      $errors++;
      $Valid_Price = false;
   }
   elseif((is_numeric($Price1) == false) || (is_numeric($Price2) == false))
   {
      ?>
      <div style="position:absolute; top:55px; left:200px; width:550px">   
        <span class="errmsg">That is not a valid Price!</span>
      </div>
      <?php     
      $errors++;
      $Valid_Price = false;
   }
   else
   {
      $Price = $Price1.".".$Price2;
      $Valid_Price = true;   
   }

   //NUS Price Validation

   if((empty($NUSPrice1)) || empty($NUSPrice2))
   {
      ?>
      <div style="position:absolute; top:70px; left:200px; width:550px">   
        <span class="errmsg">Please Enter the NUS Price</span>
      </div>
      <?php     
      $errors++;
      $Valid_NUSPrice = false;
   }
   elseif((is_numeric($NUSPrice1) == false) || (is_numeric($NUSPrice2) == false))
   {
      ?>
      <div style="position:absolute; top:70px; left:200px; width:550px">   
        <span class="errmsg">That is not a valid NUS Price!</span>
      </div>
      <?php     
      $errors++;
      $Valid_NUSPrice = false;
   }
   else
   {
      $NUSPrice = $NUSPrice1.".".$NUSPrice2;
      $Valid_NUSPrice = true;   
   }

   //Product Image Validation

   if (($Imagetype == "image/jpg") || ($Imagetype == "image/jpeg") || ($Imagetype == "image/jpe") && ($Imagesize < $Max_Size) && ($Img_Dimensions[0] <= 300) && ($Img_Dimensions[1] <=250))
   {
     if (file_exists($dirupload . $_FILES['ProductImage']['name']."jpg"))
     {
        ?>
        <div style="position:absolute; top:85px; left:200px; width:550px">   
           <span class="errmsg">That file already exists!</span>
        </div>
        <?php
        $Valid_ProductImage = false;
        $errors++;
     }

   }
   else
   {
      $Valid_ColourImage = false;
      $errors++;
      ?>
      <div style="position:absolute; top:85px; left:200px; width:550px">   
         <span class="errmsg">Please Select a .jpg image file that is no more than 300x250 pixels in size, and is less than 50kb</span>
      </div>
      <?php
   }

   //Available Sizes Section

   if(count($ASizes) > 0)
   {
      foreach($ASizes AS $Sizes)
      {
         $Valid_ASizes=True;
         $SizeA[$Sizes]= true;
         $AvailableSizes .=$Sizes."?";
         echo"<br>";
      }
   }
   else 
   {
      $Valid_ASizes=False;
      $errors++;
      ?>
      <div style="position:absolute; top:100px; left:200px; width:550px">   
         <span class="errmsg">Please select a size!</span>
      </div>
      <?php
   }

   //Available Colours Section
  
   
   if(count($AColours) > 0)
   {
      foreach($AColours AS $Colours)
      {
         $Valid_AColours=True;
         $ColourA[$Colours]= true;
         $AvailableColours .=$Colours."?";
         echo"<br>";
      }
   }
   else 
   {
      $Valid_AColours=False;
      $errors++;
      ?>
      <div style="position:absolute; top:115px; left:200px; width:550px">   
         <span class="errmsg">Please select a Colour!</span>
      </div>
      <?php
   }

   // Upload Section

   if($errors==0)
   {

   }
}

?>
<html>
<head>
  <title>Clothing Line</title>
  <link href="stylesheetCL.css" rel="stylesheet">
  <?php require('jscript.inc') ?>
</head>


</head>

<body>

  <?php require('menu.inc') ?>


<div style="position:absolute; top:75px; left:200px; width:550px">
<form method="post" enctype="multipart/form-data" action='add_product_form.php'/>

<?php
if($_POST['SubmitB'] != "Submit")
{
   ?>   
    <br>
    Clothing Code: 
    <br>
    <input type="text" MAXLENGTH="6" name="ClothingCode"/>
    <br>
    <br>
    Description: 
    <br>
    <input type="text" MAXLENGTH="30" name="Description"/>
    <br>
    <br>
    
    Item Type: 
    <br>
    <select name="ItemType"/>
    <option value="">Please Select an Item Type</option>
    <?php
   
     //Establish a connection to the Database
     $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error());

     //Select the MySQL database

     $db = mysql_select_db($Dbname, $conn);

     $sql = "SELECT ItemType FROM ItemType ORDER BY ItemType";
  
     $rs = mysql_query($sql, $conn) or die(mysql_error());
   
     while($row = mysql_fetch_array($rs))
     {
        echo"<option value='{$row['ItemType']}'>{$row['ItemType']}</option>";
     }
     mysql_close($conn);
    
     ?>
    </select>

    <br>
    <br>
    Price: 
    <br>
    <input type="int" size="1" MAXLENGTH="3" name="Price1"/>.<input type="int" MAXLENGTH="2" size="1" name="Price2"/>
    <br>
    <br>
    NUS Price: 
    <br>
    <input type="int" size="1" MAXLENGTH="3" name="NUSPrice1"/>.<input type="int" MAXLENGTH="2" size="1" name="NUSPrice2"/>
    <br>
    <br>
    Product Image: (Must be .jpg image type, 300x250 pixels in dimensions and less than 50Kb in size) 
    <br>
    <input type="file" name="ProductImage">
    <br>
    <br>
    Available Sizes:
    <br>
     <table id="Sizes">
        <tr>

        <?php

        $X=0;
        
        while($X!=7)
        {
           $Size = $CBSizes[$X];
           ?>
   <td><?php echo $Size?>:</td>
   <td><input type="checkbox" name="Sizes[]" value="<?php echo $Size?>"></td>
           </tr>
           <tr>
           <?php
           $X++;
        }
        ?>
     	</tr>
     </table>
    <br>
    Available Colours:

     <table><tr>

      <?php
      //Establish a connection to the Database

      $conn = mysql_connect($Host,$Username,$Password);

      $db = mysql_select_db($Dbname, $conn);

      $sql = "SELECT AvailableColours FROM Colours ORDER BY AvailableColours";
   
      $rs = mysql_query($sql, $conn) or die(mysql_error());

      $NumberOfColours = mysql_num_rows($rs);

      $counter = 0;

      if ($result || (mysql_num_rows($rs) > 0))
      {
         while ($row = mysql_fetch_assoc($rs)) 
         {    
            if($counter%9==0&&$counter!=0) echo "</tr><tr>";
            echo "<td><img src='/images/colours/{$row['AvailableColours']}.gif' title='{$row['AvailableColours']}'/><br />";
            echo "<td><input type='checkbox' name='Colours[]' value='{$row['AvailableColours']}'></td>";
            echo "</td>";
            ++$counter;
         }
      }
      echo "</tr></table>";
     
     mysql_close($conn); 
     ?>

   <br> 
   <br>

<?php
}
elseif($_POST['SubmitB'] == "Submit")
{
    ?>
    <br>
    Clothing Code: 
    <br>
    <input type="text" MAXLENGTH="6" name="ClothingCode" value ="<?php echo $_POST['ClothingCode']; ?>"/>
    <br>
    <br>
    Description: 
    <br>
    <input type="text" MAXLENGTH="30" name="Description" value ="<?php echo $_POST['Description']?>"/>
    <br>
    <br>

    Item Type: 
    <br>
    <select name="ItemType" value="<?php echo $_POST['ItemType']?>"/>
    <option value="">Please Select an Item Type</option>    
    <?php

     //Establish a connection to the Database
     $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error());

     //Select the MySQL database

     $db = mysql_select_db($Dbname, $conn);

     $sql = "SELECT ItemType FROM ItemType ORDER BY ItemType";
  
     $rs = mysql_query($sql, $conn) or die(mysql_error());
     
     while($row = mysql_fetch_array($rs))
     {
        $Type = $row['ItemType'];
        echo"<option value='$Type'";
        if($ItemType == $Type)
        {echo"Selected";}
        echo">$ItemType</option>";
     }
     mysql_close($conn);
     ?>

    </select>

    <br>
    <br>
    Price: 
    <br>
    <input type="int" size="1" MAXLENGTH="3" name="Price1" value="<?php echo $_POST['Price1']?>"/>.<input type="int" MAXLENGTH="2" size="1" name="Price2" value="<?php echo $_POST['Price2']?>"/>
    <br>
    <br>
    NUS Price: 
    <br>
    <input type="int" size="1" MAXLENGTH="3" name="NUSPrice1" value="<?php echo $_POST['NUSPrice1']?>"/>.<input type="int" MAXLENGTH="2" size="1" name="NUSPrice2" value="<?php echo $_POST['NUSPrice2']?>"/>
    <br>
    <br>
    Product Image: (Must be .jpg image type, 300x250 pixels in dimensions and less than 50Kb in size) 
    <br>
    
    <input type="file" name="ProductImage" value="<?php echo $_FILES['ProductImage']['name']?>"/>
    <br>
    <br>
    Available Sizes:
    <br>
     <table id="Sizes">
        <tr>
        <?php
        $X=0;
        
        while($X!=7)
        {
           $Size = $CBSizes[$X];
           
   echo"<td>$Size:</td>";
   echo"<td><input type='checkbox' name='Sizes[]' value='$Size'"; 
           if($SizeA[$Size]==true){echo"Checked";}?>
           ></td>
           </tr>
           <tr>
           <?php
           $X++;
        }
        ?>
     	</tr>
     </table>
    <br>
    Available Colours:

     <table><tr>

      <?php
      //Establish a connection to the Database

      $conn = mysql_connect($Host,$Username,$Password);

      $db = mysql_select_db($Dbname, $conn);

      $sql = "SELECT AvailableColours FROM Colours ORDER BY AvailableColours";
   
      $rs = mysql_query($sql, $conn) or die(mysql_error());

      $NumberOfColours = mysql_num_rows($rs);

      $counter = 0;
      $X = 0;

      if ($result || (mysql_num_rows($rs) > 0))
      {
         while ($row = mysql_fetch_assoc($rs)) 
         {    
            $AvailableColour = $row['AvailableColours'];
            if($counter%9==0&&$counter!=0) echo "</tr><tr>";
            echo "<td><img src='/images/colours/$AvailableColour.gif' title='$AvailableColour'/><br />";
            echo "<td><input type='checkbox' name='Colours[]' value='$AvailableColour'";  
            if($ColourA[$AvailableColour]==true)
            {echo"Checked";}
            echo "></td>";
            $X++;
            ++$counter;
         }
      }
      echo "</tr></table>";
     
     mysql_close($conn); 
     ?>

   <br> 
   <br>
   <?php
}
?>
<input type="submit" name="SubmitB" value="Submit"/>
</form>
</div>
</body>
</html>

   if (($Imagetype == "image/jpg") || ($Imagetype == "image/jpeg") || ($Imagetype == "image/jpe") && ($Imagesize < $Max_Size) && ($Img_Dimensions[0] <= 300) && ($Img_Dimensions[1] <=250))

 

Should encapsulate your or's together... like this

 

<?php
if ((($Imagetype == "image/jpg") || ($Imagetype == "image/jpeg") || ($Imagetype == "image/jpe")) && ($Imagesize < $Max_Size) && ($Img_Dimensions[0] <= 300) && ($Img_Dimensions[1] <=250)) {
?>

Okay but it still doesn't exaplin why .jpeg files aren't being restricted. I'm made a few modifications that I thought would help from other working code (I presumed they were working) found on the forum:

 

<?php

include "connect_details.php";

$CBSizes = array("XS","Small", "Medium", "Large", "XL", "XXL", "3XL");
$Submit = $_POST['SubmitB'];
$errors=0;

if($_POST['SubmitB'] =="Submit")
{
   $ClothingCode = $_POST['ClothingCode'];

   $Description = $_POST['Description'];

   $ItemType = $_POST['ItemType'];

   $Price1 = $_POST['Price1'];
  
   $Price2 = $_POST['Price2'];

   $NUSPrice1 = $_POST['NUSPrice1'];
  
   $NUSPrice2 = $_POST['NUSPrice2'];

   $ProductImage = $_FILES['ProductImage']['name'];
   $Max_Size = 51200;
   $Imagetype = $_FILES['ProductImage']['type'];
   $Imagesize = $_FILES['ProductImage']['size'];
   $image_temp = $_Files['ProductImage']['tmp_name'];
   list($width, $height) = getimagesize($image_temp);
  
   echo $Imagesize;
   echo"<br>";
   echo $Imagetype;
   echo"<br>";
   echo $width;
   echo"<br>";
   echo $height;
   echo"<br>";

   $dirupload = "../images/products/";
   $NotExec = true;

   $AColours = $_POST['Colours'];

   $ASizes = $_POST['Sizes'];
   
   //ClothingCode Validation

   if(empty($ClothingCode))
   {
      ?>
      <div style="position:absolute; top:10px; left:200px; width:550px">   
        <span class="errmsg">Please Enter the Clothing Code</span>
      </div>
      <?php     
      $errors++;
      $Valid_ClothingCode = false;
   }


   //Description Validation

   if(empty($Description))
   {
      ?>
      <div style="position:absolute; top:25px; left:200px; width:550px">   
        <span class="errmsg">Please Enter the Description</span>
      </div>
      <?php     
      $errors++;
      $Valid_Description = false;
   }

   //Item Type Validation
   
   if(empty($ItemType))
   {
      ?>
      <div style="position:absolute; top:40px; left:200px; width:550px">   
        <span class="errmsg">Please Select an Item Type!</span>
      </div>
      <?php
      $Valid_ItemType = false;
      $errors++;
   }

   //Price Validation

   if((empty($Price1)) || empty($Price2))
   {
      ?>
      <div style="position:absolute; top:55px; left:200px; width:550px">   
        <span class="errmsg">Please Enter the Price</span>
      </div>
      <?php     
      $errors++;
      $Valid_Price = false;
   }
   elseif((is_numeric($Price1) == false) || (is_numeric($Price2) == false))
   {
      ?>
      <div style="position:absolute; top:55px; left:200px; width:550px">   
        <span class="errmsg">That is not a valid Price!</span>
      </div>
      <?php     
      $errors++;
      $Valid_Price = false;
   }
   else
   {
      $Price = $Price1.".".$Price2;
      $Valid_Price = true;   
   }

   //NUS Price Validation

   if((empty($NUSPrice1)) || empty($NUSPrice2))
   {
      ?>
      <div style="position:absolute; top:70px; left:200px; width:550px">   
        <span class="errmsg">Please Enter the NUS Price</span>
      </div>
      <?php     
      $errors++;
      $Valid_NUSPrice = false;
   }
   elseif((is_numeric($NUSPrice1) == false) || (is_numeric($NUSPrice2) == false))
   {
      ?>
      <div style="position:absolute; top:70px; left:200px; width:550px">   
        <span class="errmsg">That is not a valid NUS Price!</span>
      </div>
      <?php     
      $errors++;
      $Valid_NUSPrice = false;
   }
   else
   {
      $NUSPrice = $NUSPrice1.".".$NUSPrice2;
      $Valid_NUSPrice = true;   
   }

   //Product Image Validation

   if ((($Imagetype == "image/jpg") || ($Imagetype == "image/jpeg") || ($Imagetype == "image/jpe")) && ($Imagesize < $Max_Size) && ($width <= 300) && ($height <=250))
   {
     if (file_exists($dirupload . $_FILES['ProductImage']['name']."jpg"))
     {
        ?>
        <div style="position:absolute; top:85px; left:200px; width:550px">   
           <span class="errmsg">That file already exists!</span>
        </div>
        <?php
        $Valid_ProductImage = false;
        $errors++;
     }

   }
   else
   {
      $Valid_ColourImage = false;
      $errors++;
      ?>
      <div style="position:absolute; top:85px; left:200px; width:550px">   
         <span class="errmsg">Please Select a .jpg image file that is no more than 300x250 pixels in size, and is less than 50kb</span>
      </div>
      <?php
   }

   //Available Sizes Section

   if(count($ASizes) > 0)
   {
      foreach($ASizes AS $Sizes)
      {
         $Valid_ASizes=True;
         $SizeA[$Sizes]= true;
         $AvailableSizes .=$Sizes."?";
         echo"<br>";
      }
   }
   else 
   {
      $Valid_ASizes=False;
      $errors++;
      ?>
      <div style="position:absolute; top:100px; left:200px; width:550px">   
         <span class="errmsg">Please select a size!</span>
      </div>
      <?php
   }

   //Available Colours Section
  
   
   if(count($AColours) > 0)
   {
      foreach($AColours AS $Colours)
      {
         $Valid_AColours=True;
         $ColourA[$Colours]= true;
         $AvailableColours .=$Colours."?";
         echo"<br>";
      }
   }
   else 
   {
      $Valid_AColours=False;
      $errors++;
      ?>
      <div style="position:absolute; top:115px; left:200px; width:550px">   
         <span class="errmsg">Please select a Colour!</span>
      </div>
      <?php
   }

   // Upload Section

   if($errors==0)
   {

   }
}

?>
<html>
<head>
  <title>Clothing Line</title>
  <link href="stylesheetCL.css" rel="stylesheet">
  <?php require('jscript.inc') ?>
</head>


</head>

<body>

  <?php require('menu.inc') ?>


<div style="position:absolute; top:75px; left:200px; width:550px">
<form method="post" enctype="multipart/form-data" action='add_product_form.php'/>

<?php
if($_POST['SubmitB'] != "Submit")
{
   ?>   
    <br>
    Clothing Code: 
    <br>
    <input type="text" MAXLENGTH="6" name="ClothingCode"/>
    <br>
    <br>
    Description: 
    <br>
    <input type="text" MAXLENGTH="30" name="Description"/>
    <br>
    <br>
    
    Item Type: 
    <br>
    <select name="ItemType"/>
    <option value="">Please Select an Item Type</option>
    <?php
   
     //Establish a connection to the Database
     $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error());

     //Select the MySQL database

     $db = mysql_select_db($Dbname, $conn);

     $sql = "SELECT ItemType FROM ItemType ORDER BY ItemType";
  
     $rs = mysql_query($sql, $conn) or die(mysql_error());
   
     while($row = mysql_fetch_array($rs))
     {
        echo"<option value='{$row['ItemType']}'>{$row['ItemType']}</option>";
     }
     mysql_close($conn);
    
     ?>
    </select>

    <br>
    <br>
    Price: 
    <br>
    <input type="int" size="1" MAXLENGTH="3" name="Price1"/>.<input type="int" MAXLENGTH="2" size="1" name="Price2"/>
    <br>
    <br>
    NUS Price: 
    <br>
    <input type="int" size="1" MAXLENGTH="3" name="NUSPrice1"/>.<input type="int" MAXLENGTH="2" size="1" name="NUSPrice2"/>
    <br>
    <br>
    Product Image: (Must be .jpg image type, 300x250 pixels in dimensions and less than 50Kb in size) 
    <br>
    <input type="file" name="ProductImage">
    <br>
    <br>
    Available Sizes:
    <br>
     <table id="Sizes">
        <tr>

        <?php

        $X=0;
        
        while($X!=7)
        {
           $Size = $CBSizes[$X];
           ?>
   <td><?php echo $Size?>:</td>
   <td><input type="checkbox" name="Sizes[]" value="<?php echo $Size?>"></td>
           </tr>
           <tr>
           <?php
           $X++;
        }
        ?>
     	</tr>
     </table>
    <br>
    Available Colours:

     <table><tr>

      <?php
      //Establish a connection to the Database

      $conn = mysql_connect($Host,$Username,$Password);

      $db = mysql_select_db($Dbname, $conn);

      $sql = "SELECT AvailableColours FROM Colours ORDER BY AvailableColours";
   
      $rs = mysql_query($sql, $conn) or die(mysql_error());

      $NumberOfColours = mysql_num_rows($rs);

      $counter = 0;

      if ($result || (mysql_num_rows($rs) > 0))
      {
         while ($row = mysql_fetch_assoc($rs)) 
         {    
            if($counter%9==0&&$counter!=0) echo "</tr><tr>";
            echo "<td><img src='/images/colours/{$row['AvailableColours']}.gif' title='{$row['AvailableColours']}'/><br />";
            echo "<td><input type='checkbox' name='Colours[]' value='{$row['AvailableColours']}'></td>";
            echo "</td>";
            ++$counter;
         }
      }
      echo "</tr></table>";
     
     mysql_close($conn); 
     ?>

   <br> 
   <br>

<?php
}
elseif($_POST['SubmitB'] == "Submit")
{
    ?>
    <br>
    Clothing Code: 
    <br>
    <input type="text" MAXLENGTH="6" name="ClothingCode" value ="<?php echo $_POST['ClothingCode']; ?>"/>
    <br>
    <br>
    Description: 
    <br>
    <input type="text" MAXLENGTH="30" name="Description" value ="<?php echo $_POST['Description']?>"/>
    <br>
    <br>

    Item Type: 
    <br>
    <select name="ItemType"/>
    <option value="">Please Select an Item Type</option>    
    <?php

     //Establish a connection to the Database
     $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error());

     //Select the MySQL database

     $db = mysql_select_db($Dbname, $conn);

     $sql = "SELECT ItemType FROM ItemType ORDER BY ItemType";
  
     $rs = mysql_query($sql, $conn) or die(mysql_error());
     
     while($row = mysql_fetch_array($rs))
     {
        $Type = $row['ItemType'];
        echo"<option value='$Type'";
        if($ItemType == $Type)
        {echo"Selected";}
        echo">$Type</option>";
     }
     mysql_close($conn);
     ?>

    </select>

    <br>
    <br>
    Price: 
    <br>
    <input type="int" size="1" MAXLENGTH="3" name="Price1" value="<?php echo $_POST['Price1']?>"/>.<input type="int" MAXLENGTH="2" size="1" name="Price2" value="<?php echo $_POST['Price2']?>"/>
    <br>
    <br>
    NUS Price: 
    <br>
    <input type="int" size="1" MAXLENGTH="3" name="NUSPrice1" value="<?php echo $_POST['NUSPrice1']?>"/>.<input type="int" MAXLENGTH="2" size="1" name="NUSPrice2" value="<?php echo $_POST['NUSPrice2']?>"/>
    <br>
    <br>
    Product Image: (Must be .jpg image type, 300x250 pixels in dimensions and less than 50Kb in size) 
    <br>
    
    <input type="file" name="ProductImage" value="<?php echo $_FILES['ProductImage']['name']?>"/>
    <br>
    <br>
    Available Sizes:
    <br>
     <table id="Sizes">
        <tr>
        <?php
        $X=0;
        
        while($X!=7)
        {
           $Size = $CBSizes[$X];
           
   echo"<td>$Size:</td>";
   echo"<td><input type='checkbox' name='Sizes[]' value='$Size'"; 
           if($SizeA[$Size]==true){echo"Checked";}?>
           ></td>
           </tr>
           <tr>
           <?php
           $X++;
        }
        ?>
     	</tr>
     </table>
    <br>
    Available Colours:

     <table><tr>

      <?php
      //Establish a connection to the Database

      $conn = mysql_connect($Host,$Username,$Password);

      $db = mysql_select_db($Dbname, $conn);

      $sql = "SELECT AvailableColours FROM Colours ORDER BY AvailableColours";
   
      $rs = mysql_query($sql, $conn) or die(mysql_error());

      $NumberOfColours = mysql_num_rows($rs);

      $counter = 0;
      $X = 0;

      if ($result || (mysql_num_rows($rs) > 0))
      {
         while ($row = mysql_fetch_assoc($rs)) 
         {    
            $AvailableColour = $row['AvailableColours'];
            if($counter%9==0&&$counter!=0) echo "</tr><tr>";
            echo "<td><img src='/images/colours/$AvailableColour.gif' title='$AvailableColour'/><br />";
            echo "<td><input type='checkbox' name='Colours[]' value='$AvailableColour'";  
            if($ColourA[$AvailableColour]==true)
            {echo"Checked";}
            echo "></td>";
            $X++;
            ++$counter;
         }
      }
      echo "</tr></table>";
     
     mysql_close($conn); 
     ?>

   <br> 
   <br>
   <?php
}
?>
<input type="submit" name="SubmitB" value="Submit"/>
</form>
</div>
</body>
</html>

Thank you! That has actually solved both .jpeg and .gif file problems, even if I upload an animation it still counts as the one image, animations usually stick to a certain dimension even if it's only 1 image that is that big and the rest smaller.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.