Jump to content

sungpeng

Members
  • Posts

    290
  • Joined

  • Last visited

Posts posted by sungpeng

  1. <?php
    
    include 'config2.php';
    if($_POST[action]=="Update")
    {	
    
    $check_result=0;
    $check_login=mysql_query("select * from users where email='$_POST[user]' and passwd='$_POST[pass]' and pid='$_GET[pid]'");
    $check_result=mysql_num_rows($check_login);		
    
    
    
    
    }
    
    if($check_result>0)
    {
    
    $folder_path="photo/$_GET[pid]/";
    mkdir($folder_path,0777);
    
    
    for ($i = 0; $eimages = ${'imagefile'.$i}; $i++) {
       
    if($eimages)
    {
    		$file_upload_err=0;
    		$max_file_size="10000000"; // file size in bytes
    		$max_file_size_kb="500";
    		$file_upload_err_msg="";
    
    		if($_FILES['imagefile'.$i]['size']>$max_file_size)
    		{
    			$file_upload_err_msg.="<font color='red'><strong>Image is bigger than the allowed file upload size ($max_file_size_kb kb).</strong></font><br>";
    			$file_upload_err=1;
    		}
    
    		if($eimages && ($_FILES['imagefile'.$i]['type']!="image/jpeg" && $_FILES['imagefile'.$i]['type']!="image/pjpeg"))
    		{
    			$type=$_FILES['imagefile'.$i]['type'];
    			$file_upload_err_msg.="<font color='red'><strong>Image is of a wrong file type.<br>Please upload only JPG images.</strong></font><br>";
    			$file_upload_err=1;
    		}
    
    }
    
    
    if($file_upload_err==0)
    
                 {
    
                    $get_pdt_info=mysql_query("select * from users where pid=$_GET[pid]");
            	$pdt_row=mysql_fetch_array($get_pdt_info);
    
    	        unlink("photo/$_GET[pid]/$pdt_row[imgdata]");
    
    
    
    
    
                    $pdt_id=$_GET[pid];
    
    			$folder_path="photo/$pdt_id/";
    			$image_path=$folder_path.$_FILES['imagefile'.$i]['name'];
    			$img_name=$_FILES['imagefile'.$i]['name'];
    
    			copy($eimages, "$image_path");
    
    		$update_pdt=mysql_query("update users set imgdata='$img_name' where pid=$_GET[pid]");
    
              }			
    
    
           }
    
    
    }
    
    
    ?>
    
    <html>
    
    <title>Upload an image to a database</title>
    
    
    <body>
    
    <? 
    $get_pdt_info=mysql_query("select * from instructor where pid=$_GET[pid]");
    $pdt_row=mysql_fetch_array($get_pdt_info);
    ?>
    
    
    <h2>Update with new information</h2>
    
    <form name="form" enctype="multipart/form-data" method="post" action="<?php echo"$PHP_SELF?pid=$_GET[pid]"; ?>">
    Please insert the images
    <input type='file' name='imagefile[]'>
    <input type='file' name='imagefile[]'>
    <input type='file' name='imagefile[]'>
    <br>
    
    
    <br>
    USER : <input name="user"><br>
    PASSWORD : <input name="pass"><br>
    
    
    <input type="submit" name="action" value="Update">
    </form>
    
    </body>
    </html>

     

    it doesn't work

  2. <?php
    
    include 'config2.php';
    if($_POST[action]=="Update")
    {	
    
    $check_result=0;
    $check_login=mysql_query("select * from users where email='$_POST[user]' and passwd='$_POST[pass]' and pid='$_GET[pid]'");
    $check_result=mysql_num_rows($check_login);		
    
    
    
    
    }
    
    if($check_result>0)
    {
    
    $folder_path="photo/$_GET[pid]/";
    mkdir($folder_path,0777);
    
    
    if($imagefile)
     {
    		$file_upload_err=0;
    		$max_file_size="10000000"; // file size in bytes
    		$max_file_size_kb="500";
    		$file_upload_err_msg="";
    
    		if($_FILES['imagefile']['size']>$max_file_size)
    		{
    			$file_upload_err_msg.="<font color='red'><strong>Image is bigger than the allowed file upload size ($max_file_size_kb kb).</strong></font><br>";
    			$file_upload_err=1;
    		}
    
    		if($imagefile && ($_FILES['imagefile']['type']!="image/jpeg" && $_FILES['imagefile']['type']!="image/pjpeg"))
    		{
    			$type=$_FILES['imagefile']['type'];
    			$file_upload_err_msg.="<font color='red'><strong>Image is of a wrong file type.<br>Please upload only JPG images.</strong></font><br>";
    			$file_upload_err=1;
    		}
    
    
    
    
    if($file_upload_err==0)
    
                 {
    
                    $get_pdt_info=mysql_query("select * from users where pid=$_GET[pid]");
            	$pdt_row=mysql_fetch_array($get_pdt_info);
    
    	        unlink("photo/$_GET[pid]/$pdt_row[imgdata]");
    
    
    
    
    
                    $pdt_id=$_GET[pid];
    
    			$folder_path="photo/$pdt_id/";
    			$image_path=$folder_path.$_FILES['imagefile']['name'];
    			$img_name=$_FILES['imagefile']['name'];
    
    			copy($imagefile, "$image_path");
    
    		$update_pdt=mysql_query("update users set imgdata='$img_name' where pid=$_GET[pid]");
    
              }			
    
    
           }
    
    
    }
    
    
    ?>
    
    <html>
    
    <title>Upload an image to a database</title>
    
    
    <body>
    
    <? 
    $get_pdt_info=mysql_query("select * from instructor where pid=$_GET[pid]");
    $pdt_row=mysql_fetch_array($get_pdt_info);
    ?>
    
    
    <h2>Update with new information</h2>
    
    <form name="form" enctype="multipart/form-data" method="post" action="<?php echo"$PHP_SELF?pid=$_GET[pid]"; ?>">
    Please insert the images
    <input type='file' name='imagefile'><br>
    
    
    <br>
    USER : <input name="user"><br>
    PASSWORD : <input name="pass"><br>
    
    
    <input type="submit" name="action" value="Update">
    </form>
    
    </body>
    </html>

     

    Take a look at my whole code. It can only insert one image. I want to insert 12 images, that the problem I am facing now.

  3. for ($i = 0; $eimages = ${'imagefile'.$i}; $i++) {
       
    if($eimages)
     {
    		$file_upload_err=0;
    		$max_file_size="10000000"; // file size in bytes
    		$max_file_size_kb="500";
    		$file_upload_err_msg="";
    
    		if($_FILES['imagefile'.$i]['size']>$max_file_size)
    		{
    			$file_upload_err_msg.="<font color='red'><strong>Image is bigger than the allowed file upload size ($max_file_size_kb kb).</strong></font><br>";
    			$file_upload_err=1;
    		}
    
    		if($eimages && ($_FILES['imagefile'.$i]['type']!="image/jpeg" && $_FILES['imagefile'.$i]['type']!="image/pjpeg"))
    		{
    			$type=$_FILES['imagefile'.$i]['type'];
    			$file_upload_err_msg.="<font color='red'><strong>Image is of a wrong file type.<br>Please upload only JPG images.</strong></font><br>";
    			$file_upload_err=1;
    		}
    
    }

     

    Is the coding correct?

  4. if($imagefile)
     {
    		$file_upload_err=0;
    		$max_file_size="10000000"; // file size in bytes
    		$max_file_size_kb="500";
    		$file_upload_err_msg="";
    
    		if($_FILES['imagefile']['size']>$max_file_size)
    		{
    			$file_upload_err_msg.="<font color='red'><strong>Image is bigger than the allowed file upload size ($max_file_size_kb kb).</strong></font><br>";
    			$file_upload_err=1;
    		}
    
    		if($imagefile && ($_FILES['imagefile']['type']!="image/jpeg" && $_FILES['imagefile']['type']!="image/pjpeg"))
    		{
    			$type=$_FILES['imagefile']['type'];
    			$file_upload_err_msg.="<font color='red'><strong>Image is of a wrong file type.<br>Please upload only JPG images.</strong></font><br>";
    			$file_upload_err=1;
    		}
    

     

    Good morning, I have the above code. If I would like more imagefile to go through the "if" function. How do I code? like say I have imagefile, imagefile1,imagefile2, imagefile3 so on..

  5. <?php
    
    $sql = mysql_query("SELECT * FROM users order by allstyle400 ASC LIMIT 0, 3");
    while($doing=mysql_fetch_array($sql)){
    if($doing[allstyle400]!=""){
    echo "<br/>NAME : $doing[email] speed : $doing[allstyle400] mins";
    
    }
    }
    
    ?>

     

    Hi, I need to display the top 3 lowest speed timing excluding blank cell. But it display the top 3 blank cell as blank is the lowest numbers. Pls help. Thank

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