Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "192.168.56.101";
- $username = "armando";
- $password = "qwerty123";
- $db = "demo_game_changer";
- try {
- $conn = new mysqli_connect($servername, $username, $password, $db);
- 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 leads (domain,user_id,in_list,date_callback)
- values ('".$getData[0]."','0','0','2017-05-16')";
- $result = mysqli_query($conn, $sql);
- if(!isset($result))
- {
- echo "<script type=\"text/javascript\">
- alert(\"Invalid File:Please Upload CSV File.\");
- window.location = \"index.php\"
- </script>";
- }
- else {
- echo "<script type=\"text/javascript\">
- alert(\"CSV File has been successfully Imported.\");
- window.location = \"index.php\"
- </script>";
- }
- }
- fclose($file);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement