I have html input fields.
Those input fields are
1.name
2.title
3.lyrics
4.upload
Now I need to save name, title, lyrics and upload files into database at same time.How to do this??
Here I share my codes
<?php
$connection = mysqli_connect("localhost", "root", "upload"); //
Establishing Connection with Server
$db = mysqli_select_db($connection, "song"); // Selecting Database from
Server
if(isset($_POST['submit'])){ // Fetching variables of the form which
travels in URL
$name = $_POST['name'];
$title = $_POST['title'];
$lyrics = $_POST['lyrics'];
if($name !=''||$title !=''||$lyrics !=''){
//Insert Query of SQL
$query = mysqli_query($connection, "insert into users(name, title,
lyrics) values ('$name', '$title', '$lyrics')");
echo "<br/><br/><span>Data Inserted successfully...!!</span>";
}
else{
echo "<p>Insertion Failed <br/> Some Fields are Blank....!!</p>";
}
}
mysqli_close($connection); // Closing Connection with Server
?>
<div style="margin:1em auto; width:333px; text-align:center;">
<form method="post" enctype="multipart/form-data">
<table style="margin-top: 200px;line-height: 27px;">
<tr><td><label for='name' >Name: </label></td>
<td> <input type="text" name="name"></td></tr>
<tr><td> <label for='title' >Title: </label></td>
<td> <input type="text" name="title"></td></tr>
<tr><td> <label for='lyrics' >lyrics: </label></td>
<td><textarea cols="25" name="lyrics" rows="5"></textarea></td></tr>
<tr> <td> <label for='file'>upload:</label></td>
<td><input type="file" name="files" multiple="multiple"></td>
<td><input type="submit" name="upload" value="upload!" ></td></tr>
</table>
<button class="submit" name="submit" type="submit"
value="Insert">save</button>
</form>
</div>
I will save name, title, lyrics data into database.
But when I try to save upload file into database, it shows an error