WiredWX Christian Hobby Weather Tools
Would you like to react to this message? Create an account in a few clicks or log in to continue.

WiredWX Christian Hobby Weather ToolsLog in

 


descriptionupdating an upload form Emptyupdating an upload form

more_horiz
sorry about the title, i just don't know how to call my problem.

to start with, i have a 2 php pages.

Page A.php (an update page)
- contains text boxes, drop down lists, an upload file option and a submit button. when you click submit, all details will go to page B.php. All text boxes have default values as well as the upload file option. so that when i edit it,


Code:

 
        input type="text" name="namec" id="name" value="<?php echo $employees->name ?>"
        input type="file" name="file" id="file" value="<?php echo $employees->file ?>"
       


Page B.php
- saves the updates from page A. contains php codes.


Problem.
when i update page A all details from the text boxes, drop down list and upload file are saved to my database but when i update page A without browsing for a file to upload, all the details from the text boxes and lists are saved but then my database gets overwritten. what happens is that, emp_file from my database is now empty.


sorry or the explanation. i hope its understandable
Yikes

............................................................................................

updating an upload form Charvi10

THIS SIGNATURE IS BY::: AGENT COSMIC ----------QUOTE BY:::TECHY

descriptionupdating an upload form EmptyRe: updating an upload form

more_horiz
Hi charvie and sorry for the late response,

It sounds to me like the problem is with your SQL for updating your database rather than the file input itself. Can we see the code for when you are updating in B.php?

............................................................................................



There are no stupid questions, only those too stupid to ask for help.

descriptionupdating an upload form EmptyRe: updating an upload form

more_horiz
thank you for the response..here's the code.

Code:

<?php
session_start();
require_once('classes/Employee.php');
$empID = $_POST['id'];


if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br />";
  }
else
  {
 if (($_FILES["file"]["type"] == "application/pdf")||($_FILES["file"]["type"] != "application/pdf")||($_FILES["file"]["type"] !="application/pdf"))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    $_SESSION['pdf'] = $_FILES["file"]["name"];   
   }


      move_uploaded_file($_FILES["file"]["tmp_name"],"pdf_records/" . $_FILES["file"]["name"]);
   
  }
    
   else
    {
      echo "Invalid file";
    }
 
  echo "<tr><td> $caption </td></tr>";
     echo "</table>";
}   






if ($_FILES["file2"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file2"]["error"] . "<br />";
  }
else
  {
 if (($_FILES["file2"]["type"] == "image/jpeg")||($_FILES["file2"]["type"] != "image/jpeg")||($_FILES["file2"]["type"] !="image/jpeg"))
  {
  if ($_FILES["file2"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file2"]["error"] . "<br />";
    }
  else
    {
    $image = $_FILES["file2"]["name"];   
   }


      move_uploaded_file($_FILES["file2"]["tmp_name"],"emp_images/" . $_FILES["file2"]["name"]);
   
  }
    
   else
    {
      echo "Invalid file";
    }
 
  echo "<tr><td> $caption </td></tr>";
     echo "</table>";
}   



if ($_FILES["file3"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file3"]["error"] . "<br />";
  }
else
  {
 if (($_FILES["file3"]["type"] == "application/pdf")||($_FILES["file3"]["type"] != "application/pdf")||($_FILES["file3"]["type"] !="application/pdf"))
  {
  if ($_FILES["file3"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file3"]["error"] . "<br />";
    }
  else
    {
    $image = $_FILES["file3"]["name"];   
   }


      move_uploaded_file($_FILES["file3"]["tmp_name"],"pdf_records/" . $_FILES["file3"]["name"]);
   
  }
    
   else
    {
      echo "Invalid file";
    }
 
  echo "<tr><td> $caption </td></tr>";
     echo "</table>";
}   
?>

<?php


$time= time("H,i,s", time());
$date = date("Y-m-d",$time);
$_POST['date'] = date("Y-m-d",$time);

if ($_POST['Submit']) {
       $employees = new Employee();
   
       $employees->emp_id             = $_POST['id'];
        $employees->emp_fname          = $_POST['fname'];
        $employees->emp_lname          = $_POST['lname'];
        $employees->emp_mname          = $_POST['mname'];
        $employees->emp_bdate           = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
        $employees->emp_gender          = $_POST['gender'];
        $employees->emp_contact_no       = $_POST['contact_no'];
        $employees->emp_address       = $_POST['address'];
        $employees->emp_civil_status     = $_POST['cstatus'];
        $employees->emp_datehired     =  $_POST['dyear']."-".$_POST['dmonth']."-".$_POST['dday'];
        $employees->emp_wage          = $_POST['wage'];
        $employees->emp_password        = $_POST['password'];
        $employees->emp_username       = $_POST['username'];
        $employees->emp_occupation     = $_POST['occupation'];
        $employees->emp_status        =$_POST['status'];
        $employees->emp_pdfrec          = $_FILES["file"]["name"];
        $employees->emp_sss          = $_POST['sss'];
        $employees->emp_philhealth       = $_POST['philhealth'];
        $employees->emp_tin          = $_POST['tin'];
        $employees->emp_bankacc       = $_POST['bankacc'];
        $employees->emp_image          = $_FILES["file2"]["name"];
        $employees->emp_update_history    = $_POST['date'];   
             
      if ($employees->updateEmployee()) {
           //na update siya
           if ($employees->emp_occupation == "System Administrator")
               header('location: viewemployee.php?id='.$_POST['id'].'&updated=true');
            else
               header('location: viewemployee.php?id='.$_POST['id'].'&updated=true');
         
        } else {
            // naay error
            header('location: admin_index.php?page=errormsg');
        }
   
} else{
   if ($_POST['occupation'] == "System Administrator")
      header('location: admin_index.php?page=myaccount');
   else
      header('location: viewemployee.php?id='.$_POST['id']);
}
      
   
?>

............................................................................................

updating an upload form Charvi10

THIS SIGNATURE IS BY::: AGENT COSMIC ----------QUOTE BY:::TECHY

descriptionupdating an upload form EmptyRe: updating an upload form

more_horiz
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum