Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form class="ui input" enctype="multipart/form-data" method = "POST" role = "form">
- <input type = "file" name ="file" id="file" size = "150">
- <button class="ui small red button" type = "submit" class = "btn btn-default" name ="submit" value = "submit">Upload CSV</button>
- </form>
- <?php
- if(isset($_POST['submit'])) {
- $host = 'localhost';
- $user = 'root';
- $password = '';
- $db = 'jeremy_db';
- $con = mysqli_connect($host,$user,$password) or die('Could not' .mysqli_error($con));
- mysqli_select_db($con, $db) or die ('Could not' .mysqli_error($con));
- $file = $_FILES['file']['tmp_name'];
- $handle = fopen($file, "r");
- $c = 0;
- while(($csvdata = fgetcsv($handle,1000,","))!== FALSE){
- $sha1 = $csvdata[0];
- $vsdt = $csvdata[1];
- $trendx = $csvdata[2];
- $sql = "INSERT INTO jeremy_table_trend (sha1,vsdt,trendx) VALUES ('$sha1','$vsdt','$trendx')";
- $query = mysqli_query($con , $sql);
- $c = $c+1;
- }
- if($query){
- echo "SABRE";
- }
- else {
- echo "SLAM";
- }
- }
- ?>
Add Comment
Please, Sign In to add comment