<form  action="insertresubmittedpaper.php" autocomplete="on" enctype="multipart/form-data" method="post"> 
                               <h1>Re-Submit Paper</h1>
                                 
         
        
        
        
        <p>
        
        
        
       
        <input type="file" name="uploaded_file"><br>
                               
       
        </p>
        
        
        
        
        <br>
         
      <br>
                                <center> 
        <p class="submit button"> 
                                <input type="submit" value="Submit"> 
        </p>
        </center>
        
                            </form>Hello I'm working on a project where I need to insert a file into database, and after that I have an option where the user can update the existing file in database using a form and when once updated it will be redirected to another page. I'm using PHP , mysql.
The Problem is a new file is not being updated into the database, but it is redirecting to another page. Here i'm posting my code. Please suggest me necessary changes.
<?php
session_start(); 
if(isset($_SESSION['username']))  
  { 
  echo "<div id='User'>Welcome: " . $_SESSION['username'] . "</div>"; 
  }  
else 
   { 
     echo "<div id='Guest'>Welcome: Guest </div>"; 
     } 
/*
Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password)
*/
if(isset($_FILES['uploaded_file'])) {
    // Make sure the file was sent without errors
    if($_FILES['uploaded_file']['error'] == 0) {
$link = mysqli_connect("localhost", "kuda", "secret", "researchcloud");
// Check connection
if($link === false)
{
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
$UserName=$_SESSION['username'];
$Subject = mysqli_real_escape_string($link, $_POST['subject']);
$Category = mysqli_real_escape_string($link, $_POST['category']);
$Journal = mysqli_real_escape_string($link, $_POST['journal']);
$mime = mysqli_real_escape_string($link, $_FILES['uploaded_file']['type']);
$data = mysqli_real_escape_string($link, file_get_contents($_FILES  ['uploaded_file'] ['tmp_name'] ));
// attempt insert query execution
$sql = "UPDATE rc_ijai set FullPaper='$data', mime='$mime' where A1Email='$UserName' and Journal='$Journal'";
 if(mysqli_query($link, $sql))
 {
 header('Location:authorprofile.php');
} 
else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
mysqli_close($link);
}
}
else {
        echo 'An error occurred while the file was being uploaded. '
           . 'Error code: '. intval($_FILES['uploaded_file']['error']);
    }
?>
 
    