File manager - Edit - /home/autoph/public_html/voc/home/sample/FILE_UPLOAD_index.php
Back
<!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" crossorigin="anonymous"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" crossorigin="anonymous"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" crossorigin="anonymous"></script> </head> <?php function get_all_records(){ $con = getdb(); $Sql = "SELECT * FROM employeeinfo"; $result = mysql_query($con, $Sql); if (mysql_num_rows($result) > 0) { echo "<div class='table-responsive'><table id='myTable' class='table table-striped table-bordered'> <thead><tr><th>EMP ID</th> <th>First Name</th> <th>Last Name</th> <th>Email</th> <th>Registration Date</th> </tr></thead><tbody>"; while($row = mysqli_fetch_assoc($result)) { echo "<tr><td>" . $row['emp_id']."</td> <td>" . $row['firstname']."</td> <td>" . $row['lastname']."</td> <td>" . $row['email']."</td> <td>" . $row['reg_date']."</td></tr>"; } echo "</tbody></table></div>"; } else { echo "you have no records"; } } function getdb(){ $servername = "localhost"; $username = "root"; $password = "aee1024"; $dbname = "db_vts"; try { $conn = mysql_connect($servername, $username, $password, $dbname); //echo "Connected successfully"; } catch(exception $e) { echo "Connection failed: " . $e->getMessage(); } return $conn; } if(isset($_POST["Import"])){ $filename=$_FILES["file"]["tmp_name"]; if($_FILES["file"]["size"] > 0) { $file = fopen($filename, "r"); while (($getData = fgetcsv($file, 10000, ",")) !== FALSE) { $sql = "INSERT into login_history (log_id,u_name,date,time,remarks, branch_code) values ('','".$getData[1]."','".$getData[2]."','".$getData[3]."','".$getData[4].",'".$getData[5]."')"; $result = mysql_query($con, $sql); if(!isset($result)) { echo "<script type=\"text/javascript\"> alert(\"Invalid File:Please Upload CSV File.\"); window.location = \"FILE_UPLOAD_index.php\" </script>"; } else { echo "<script type=\"text/javascript\"> alert(\"CSV File has been successfully Imported.\"); window.location = \"FILE_UPLOAD_index.php\" </script>"; } } fclose($file); } } ?> <body> <div id="wrap"> <div class="container"> <div class="row"> <form class="form-horizontal" action="" method="post" name="upload_excel" enctype="multipart/form-data"> <fieldset> <!-- Form Name --> <legend>Form Name</legend> <!-- File Button --> <div class="form-group"> <label class="col-md-4 control-label" for="filebutton">Select File</label> <div class="col-md-4"> <input type="file" name="file" id="file" class="input-large"> </div> </div> <!-- Button --> <div class="form-group"> <label class="col-md-4 control-label" for="singlebutton">Import data</label> <div class="col-md-4"> <button type="submit" id="submit" name="Import" class="btn btn-primary button-loading" data-loading-text="Loading...">Import</button> </div> </div> </fieldset> </form> </div> <?php get_all_records(); ?> </div> </div> </body> </html>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings