i have a text file as abc.txt which looks like
hi hello john
how are you jelly
fine thank u
now i need a php code to select this file from html page and read this text file line by line and store each line as a seperate row in mysql database.
my html code is
<html>
<body>
<table align="center">
<form action="upload_page.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
</table>
</body>
</html>
i need help to improve upload_page code
<?php
$a=$_POST['file'];
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
mysql_select_db($db) or die ("Unable to select database!");
$lines = file('$a');
foreach($lines as $num => $line)
mysql_query('insert into file_tbl (file_data) values ("' . mysql_real_escape_string($line) . '");');
?>
any help is appreciated