Advertisement
Guest User

Untitled

a guest
Jul 14th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org
  2. /TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <?php
  4.  
  5. $user =$_POST['user'];
  6.  
  7. ?>
  8. <html>
  9. <head>
  10. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  11. <title>MySql to CSV script by www.erriko.it</title>
  12. <style type="text/css">
  13. body{
  14. background:#dedede;
  15. margin:0;
  16. padding:0;
  17. }
  18. #wrapper{
  19. width:100%;
  20. }
  21. #form{
  22. margin-left:auto;
  23. margin-right:auto;
  24. margin-top:100px;
  25. width:400px;
  26. padding:20px;
  27. background:#efefef;
  28. border:2px solid #2e2e2e;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33.  
  34. <div id="wrapper">
  35. <div id="form">
  36.  
  37. <?php
  38. $user = $_POST[$user];
  39. print $user ;
  40.  
  41. $host = $_POST['host']; // <-- inserisci qui l'indirizo ip di MySql
  42. $user = $_POST['user']; // <-- nome utente del database
  43. $pass = $_POST['pass']; // <-- password dell'utente
  44. $db = $_POST['db']; // il database desiderato
  45. $table = $_POST['table']; // la tabella da esportare in .csv
  46. $file = $table; // il nome del file csv da generare
  47.  
  48. $link = mysql_connect($host, $user, $pass) or die("Can not connect." .
  49. mysql_error());
  50. /* usa i dati forniti per connetterti a MySql, se impossibile interrompi */
  51.  
  52. mysql_select_db($db) or die("Can not connect.");
  53. // seleziona il db desiderato oppure interrompi
  54.  
  55. $result = mysql_query("SHOW COLUMNS FROM ".$table."");
  56. $i = 0;
  57. if (mysql_num_rows($result) > 0) {
  58. while ($row = mysql_fetch_assoc($result)) {
  59. $csv_output .= $row['Field']."; ";
  60. $i++;
  61. }
  62. }
  63. $csv_output .= "n";
  64.  
  65. $values = mysql_query("SELECT * FROM ".$table."");
  66. while ($rowr = mysql_fetch_row($values)) {
  67. for ($j=0;$j<$i;$j++) {
  68. $csv_output .= $rowr[$j]."; ";
  69. }
  70. $csv_output .= "n";
  71. }
  72. $filename = $file."_".date("d-m-Y_H-i",time());
  73. // il nome del file sara' composto da quello scelto all'inizio e la data ed ora oggi
  74. /* setta le specifiche del file csv */
  75. header("Content-type: application/vnd.ms-excel");
  76. header("Content-disposition: csv" . date("Y-m-d") . ".csv");
  77. header( "Content-disposition: filename=".$filename.".csv");
  78. print $csv_output; // il file e' pronto e puo' essere scaricato
  79. exit;
  80. ?>
  81. </div>
  82. </div>
  83. </body>
  84. </html>`
  85.  
  86. table 1
  87. table 2
  88. table 3
  89.  
  90. login.php
  91. <html>
  92. <body>
  93. <form name="myform" action="secondpage.php" method="post">
  94. <div>Username: <input type="text" name="username" value="" /></div>
  95.  
  96. <div>Password: <input type="password" name="password" value="" /></div>
  97.  
  98. <div> <input type="submit" /> </div>
  99. </form>
  100. </body>
  101. </html>
  102.  
  103. secondpage.php
  104. <html>
  105. <body>
  106.  
  107. Welcome <?php echo $_POST["username"]; ?>!<br />
  108. Your password is: <?php echo $_POST["password"]; ?>
  109.  
  110. </body>
  111. </html>
  112.  
  113. $host = $_POST['host']; // <-- inserisci qui l'indirizo ip di MySql
  114. $user = $_POST['user']; // <-- nome utente del database
  115. $pass = $_POST['pass']; // <-- password dell'utente
  116. $db = $_POST['db']; // il database desiderato
  117. $table = $_POST['table']; // la tabella da esportare in .csv
  118. $file = $table; // il nome del file csv da generare
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement