This is the form where i can upload the image file:

<?php 
require_once ('includes/config.inc.php'); 
session_start();

// If no first_name session variable exists, redirect the user:
if (!isset($_SESSION['first_name'])) {

    $url = BASE_URL . 'index.php'; // Define the URL.
    ob_end_clean(); // Delete the buffer.
    header("Location: $url");
    exit(); // Quit the script.

}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Change Company Logo</title>
</head>

<body>
<form action="change-company-logo-process.php" method="POST" enctype="multipart/form-data" name="form1" class="contact_form" id="select2">
<input type="hidden" name="userid1" value="<?php echo $_SESSION['user_id']; ?>"/>
<input type="hidden" name="rn1" value="<?php echo $_SESSION['webname'];?>"  />
<input type="hidden" name="ext1" value=".jpg" />
<input type="file" name="file1" required><br>
<button class="submit"  name="Submit" type="submit">Upload</button>
<input name="hdnLine" type="hidden" value="1">
</form>
</body>
</html>
<?php

 // Flush the buffered output.
ob_end_flush();
?>

This is the Image processing Code:

<?php 
// Initialize a session:
session_start();
require_once ('includes/config.inc.php'); 
         require('../connections/dbconnect.php'); 


// Start output buffering:
ob_start();


?>
<?


function getExtension($str) {

         $i = strrpos($str,".");
         if (!$i) { return ""; } 
         $l = strlen($str) - $i;
         $ext = substr($str,$i+1,$l);
         return $ext;
 }


 define ("MAX_SIZE","4000");

 $errors=0;
 //function for file array eg. file1-file2-file3-file4-file5
 for($i=1;$i<=(int)($_POST["hdnLine"]);$i++)
 if($_POST["rn".$i] != "")
 if($_POST["userid".$i] != "")

 //end          

 if($_SERVER["REQUEST_METHOD"] == "POST")
 {
        $image =$_FILES["file".$i]["name"];
 $uploadedfile = $_FILES['file'.$i]['tmp_name'];

  if ($image) 
  {
  $filename = stripslashes($_FILES['file'.$i]['name']);
        $extension = getExtension($filename);
  $extension = strtolower($extension);
 if (($extension != "jpg") && ($extension != "jpeg") 
&& ($extension != "png") && ($extension != "gif")) 
  {
echo ' Unknown Image extension ';
$errors=1;
  }
 else
{
   $size=filesize($_FILES['file'.$i]['tmp_name']);

if ($size > MAX_SIZE*1024)
{
 echo "You have exceeded the size limit";
 $errors=1;
}

if($extension=="jpg" || $extension=="jpeg" )
{
$uploadedfile = $_FILES['file'.$i]['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png")
{
$uploadedfile = $_FILES['file'.$i]['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}
else 
{
$src = imagecreatefromgif($uploadedfile);
}

list($width,$height)=getimagesize($uploadedfile);
/*
$newwidth1=57;
$newheight1=($height/$width)*$newwidth1;
if($newheight1 > 10) { 
$newheight=300;
$newwidth=($newwidth1/$newheight1)*$newheight;
} else {
$newheight = $newheight1;
$newwidth = $newwidth1; }
*/

$newwidth=300;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);

$newwidth1=75;
$newheight1=($height/$width)*$newwidth1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1);
//mini
$newwidth2=40;
$newheight2=($height/$width)*$newwidth2;
$tmp2=imagecreatetruecolor($newwidth2,$newheight2);

imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,
 $width,$height);

imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1, 
$width,$height);

imagecopyresampled($tmp2,$src,0,0,0,0,$newwidth2,$newheight2, 
$width,$height);

$filename = "../images/company_logo/".$_POST["userid".$i]."_".$_POST["rn".$i]."_cl.".$extension;
$filename1 = "../images/company_logo/thumb/".$_POST["userid".$i]."_".$_POST["rn".$i]."_cl.".$extension;
$filename2 = "../images/company_logo/thumb/mini/".$_POST["userid".$i]."_".$_POST["rn".$i]."_cl.".$extension;
//if(isset($_POST['hdnLine']))

 $email = $_SESSION['email'];
{


$strSQL1 = "UPDATE users SET company_logo='".$_POST["userid".$i]."_".$_POST["rn".$i]."_cl.".$extension."' WHERE user_id = ".$_POST["userid".$i]." ";
$strSQL2 = "UPDATE jd_postdetails set avatar='".$_POST["userid".$i]."_".$_POST["rn".$i]."_cl.".$extension."' WHERE publisherid = ".$_POST["userid".$i]." ";
$strSQL3 = "UPDATE jd_subscription SET fromcompanylogo='".$_POST["userid".$i]."_".$_POST["rn".$i]."_cl.".$extension."' WHERE frompublisherid = ".$_POST["userid".$i]." ";
$strSQL4 = "UPDATE jd_activity set like_companylogo='".$_POST["userid".$i]."_".$_POST["rn".$i]."_cl.".$extension."' WHERE  publisherid = ".$_POST["userid".$i]." ";
$strSQL5 = "UPDATE jd_activity set subs_companylogo='".$_POST["userid".$i]."_".$_POST["rn".$i]."_cl.".$extension."' WHERE  publisherid = ".$_POST["userid".$i]." ";
                    //$strSQL5 = "UPDATE jd_likepost set avatar='".$_POST["userid".$i]."_".$_POST["rn".$i].".".$extension."' WHERE  email= ".$email." ";
//                  $strSQL .="(image WHERE pid='".$_POST["pid".$i]."') VALUES ('".$_POST["pid".$i].$_POST["ext".$i]."')";
                    mysql_query($strSQL1);
                    mysql_query($strSQL2);
                    mysql_query($strSQL3);
                    mysql_query($strSQL4);
                    mysql_query($strSQL5);

    }

imagejpeg($tmp,$filename,100);
imagejpeg($tmp1,$filename1,100);
imagejpeg($tmp2,$filename2,100);

imagedestroy($src);
imagedestroy($tmp);
imagedestroy($tmp1);
imagedestroy($tmp2);
}
}
}
//If no errors registred, print the success message

 if(isset($_POST['Submit']) && !$errors) 
 {

echo '<meta http-equiv="refresh" content="0;URL=account-settings.php" />';   

        mysql_close();   
 }
 ?>

    <?
    ob_end_flush();
    ?>

I have a problem on this Code by updating my databse..actually on my Localhost it's working
but when i test it online it's not working..

Are you getting an error message at all?

Are you amending

require_once ('includes/config.inc.php');
require('../connections/dbconnect.php');

to ensure the correct login details

acctually on my localhost (offline) ,It's working "no problem"... but when i tried it online.not working.. i don't no what wrong..coz no error appear..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.