Advertisement
Guest User

Untitled

a guest
Jun 15th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. bangladesh_info (Division,District,Thana,Union)
  2.  
  3. "new records created successfully"
  4.  
  5. <?php
  6.  
  7.  
  8. if(isset($_POST['text']) && !empty($_POST['text'])){
  9.  
  10. $servername = "localhost";
  11. $username = "root";
  12. $password = "";
  13. $dbname = "myown";
  14. try{
  15. $conn = new PDO("mysql:host={$servername};dbname={$dbname}", $username, $password);
  16. $stmt = $conn->prepare("INSERT INTO bangladesh_info (Division,District,Thana,Union)
  17. VALUES (:division, :district, :thana,:union)");
  18. $stmt->bindParam(':division', $division);
  19. $stmt->bindParam(':district', $district);
  20. $stmt->bindParam(':thana', $thana);
  21. $stmt->bindParam(':union',$union);
  22. $myarr=explode("n",$_POST['text']);
  23. foreach($myarr as $each){
  24.  
  25. list($div,$dis,$tha,$uni)=explode(',',$each);
  26. echo $uni.'</br>';
  27.  
  28. $division=$div;
  29. $district=$dis;
  30. $thana=$tha;
  31. $union=$uni;
  32. $stmt->execute();
  33.  
  34. }
  35. echo "New records created successfully";
  36.  
  37. }
  38. catch(PDOException $e)
  39. {
  40. echo "Error: " . $e->getMessage();
  41. }
  42. }
  43.  
  44. ?>
  45.  
  46. <html>
  47. <body>
  48. <form action='<?php echo $_SERVER["PHP_SELF"] ; ?>' method='POST' >
  49. <textarea name='text' id='mytextarea'></textarea>
  50. <input type='submit' value='submit' >
  51. </form>
  52. <script>
  53.  
  54. </script>
  55. </body>
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement