One Hat Cyber Team
Your IP :
172.70.80.190
Server IP :
188.114.97.4
Server :
Linux thuru 6.5.11-4-pve #1 SMP PREEMPT_DYNAMIC PMX 6.5.11-4 (2023-11-20T10:19Z) x86_64
Server Software :
Apache/2.4.51 (Unix) OpenSSL/1.0.2k-fips
PHP Version :
7.3.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
thuruk
/
public_html
/
App
/
New
/
admin
/
dashboard
/
View File Name :
save_csv_data.php
<?php session_start(); ?> <?php include('../../connections.php'); ?> <?php if(isset($_POST['submit'])) { try { // Define file details $fileName = $_FILES['file']['name']; $fileTmpName = $_FILES['file']['tmp_name']; $fileType = $_FILES['file']['type']; // Check if file is a CSV if($fileType !== 'text/csv') { die("Error: Please upload a CSV file."); } // Open file and read data $file = fopen($fileTmpName, "r"); // Skip the first row (header) fgetcsv($file); // Loop through data and insert into database while (($data = fgetcsv($file, 1000, ",")) !== FALSE) { // Escape data to prevent SQL injection $phone = mysqli_real_escape_string($connect, $data[0]); $name = mysqli_real_escape_string($connect, $data[1]); $city = mysqli_real_escape_string($connect, $data[2]); $email = mysqli_real_escape_string($connect, $data[3]); $currentDate = date('Y-m-d'); $hash = md5($phone); // Insert data into database $sql = "INSERT INTO `users`(`user_id`, `name`, `city`, `email`, `password`, `created_date`, `profile`, `status`) VALUES ('$phone','$name','$city','$email','$hash','$currentDate','','')"; if(mysqli_query($connect, $sql)) { echo "Record added successfully.<br>"; } else { echo "Error: " . mysqli_error($connect) . "<br>"; } } // Close file and database connection fclose($file); mysqli_close($connect); } catch (Exception $e) { // handle the exception } } ?>