Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bangladesh_info (Division,District,Thana,Union)
- "new records created successfully"
- <?php
- if(isset($_POST['text']) && !empty($_POST['text'])){
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "myown";
- try{
- $conn = new PDO("mysql:host={$servername};dbname={$dbname}", $username, $password);
- $stmt = $conn->prepare("INSERT INTO bangladesh_info (Division,District,Thana,Union)
- VALUES (:division, :district, :thana,:union)");
- $stmt->bindParam(':division', $division);
- $stmt->bindParam(':district', $district);
- $stmt->bindParam(':thana', $thana);
- $stmt->bindParam(':union',$union);
- $myarr=explode("n",$_POST['text']);
- foreach($myarr as $each){
- list($div,$dis,$tha,$uni)=explode(',',$each);
- echo $uni.'</br>';
- $division=$div;
- $district=$dis;
- $thana=$tha;
- $union=$uni;
- $stmt->execute();
- }
- echo "New records created successfully";
- }
- catch(PDOException $e)
- {
- echo "Error: " . $e->getMessage();
- }
- }
- ?>
- <html>
- <body>
- <form action='<?php echo $_SERVER["PHP_SELF"] ; ?>' method='POST' >
- <textarea name='text' id='mytextarea'></textarea>
- <input type='submit' value='submit' >
- </form>
- <script>
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement