Write a programme using file upload

<html>
<head></head>
<body>
<form action="" method="post" enctype="multipart/form-data">

    <table border="2"><tr><th>    Select Image File to Upload:</th><th><input type="file" name="file">
    </th></tr><tr><th>Name :</th><th><input type="text" name="title"></th></tr>
    <tr><th>Roll no.:</th><th><input type="text" name="name"></th></tr>
        <tr><th>English marks</th><th><input type="text" name="name1"></th></tr><tr><th>Maths marks</th><th>
                <input type="text" name="name2"></th></tr><tr><th>Science marks</th><th>
                        <input type="text" name="name3"></th></tr></table>
    <input type="submit" name="submit" value="Upload">
</form>

<?php
// Database configuration
$dbHost     = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName     = "fileupnew";

// Create database connection
$conn = mysqli_connect($dbHost, $dbUsername, $dbPassword, $dbName);

if(isset($_POST["submit"])){
$name=$_POST["name"];
$title=$_POST["title"];
$name1=$_POST["name1"];
$name2=$_POST["name2"];
$name3=$_POST["name3"];

$pname=rand(1000,10000)."_".$_FILES["file"]["name"];
$tname=$_FILES["file"]["tmp_name"];
$upload_dir="images/";
 move_uploaded_file($tname,$upload_dir.'/'.$pname);
 $sql="INSERT into file(title,image,name,name1,name2,name3) VALUES('$title','$pname','$name','$name1','$name2','$name3')";
 if(mysqli_query($conn,$sql))
 {
    echo"file upload sucessfully";
 }
else
{
echo"error";
}

}    
?>

</body>
</html>

 Write a programme of file upload and display

<html>
<body><form method="post" enctype="multipart/form-data">
<input type="text" name="a"><input type="text" name="b"><input type="text" name="c"><input type="submit" name="submit"></form><?php
if(isset($_POST["submit"])){
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "fileupnew";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$a=$_POST['a'];
$b=$_POST['b'];
$c=$_POST['c'];
$sql="INSERT into fileupnew8(a1,b1,c1) VALUES('$a','$b','$c')";
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT a1,b1,c1 FROM fileupnew8";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
  // output data of each row
  while($row = $result->fetch_assoc()) {
    echo "id: " . $row["a"]. " - Name: " . $row["b"]. " " . $row["c"]. "<br>";
  }
} else {
  echo "0 results";
}
$conn->close();
}
?>