Advertisement
Guest User

Untitled

a guest
May 15th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. <form action="insert.php" method="post" />
  2. <table id="Wagen">
  3. <thead>
  4. <tr>
  5. <th>Typ</th>
  6. <th>Kennzeichen</th>
  7. <th>Bericht</th>
  8. <th>Fahrer</th>
  9. </tr>
  10. </thead>
  11.  
  12. <tbody>
  13.  
  14. <?php
  15. $url = ('./cars.xml');
  16. $xml = simplexml_load_file( urlencode($url), null, true);
  17.  
  18.  
  19. foreach ( $xml->car as $cars ) :?>
  20. <tr>
  21. <td><input type="hidden" name="name[]" value="<?php echo $cars->typ; ?>"><?php echo $cars->typ; ?></td>
  22. <td><input type="hidden" name="kfz-nr[]" value="<?php echo $cars->plate; ?>"><?php echo $cars->plate; ?></td>
  23. <td><input type="hidden" name="bericht[]" value="<?php echo $cars->message; ?>"><?php echo $cars->message; ?></td>
  24. <td><input type="hidden" name="fahrer[]" value="<?php echo $cars->driver; ?>"><?php echo $cars->driver; ?></td>
  25. </tr>
  26.  
  27. <?php endforeach; ?>
  28.  
  29. </tbody>
  30. </table>
  31. <input type="submit" name="senden" value="XML speichern" />
  32. </form>
  33.  
  34. <?php
  35.  
  36. error_reporting(E_ALL);
  37. $MYSQL_HOST = 'localhost';
  38. $MYSQL_USER = 'username';
  39. $MYSQL_PASS = 'password';
  40. $MYSQL_DATA = 'database';
  41.  
  42. $connid = @mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASS) OR die("Error: ".mysql_error());
  43. mysql_select_db($MYSQL_DATA) OR die("Error: ".mysql_error());
  44.  
  45. if (isset($_POST['senden']))
  46. {
  47. $sql =
  48. "INSERT INTO myTable
  49. (fahrzeug,
  50. kennzeichen,
  51. bericht,
  52. fahrer
  53. )
  54. VALUES
  55. ('".mysql_real_escape_string(trim($_POST['name']))."',
  56. '".mysql_real_escape_string(trim($_POST['kfz-nr']))."',
  57. '".mysql_real_escape_string(trim($_POST['bericht']))."',
  58. '".mysql_real_escape_string(trim($_POST['fahrer']))."');
  59. mysql_query($sql) OR die("<pre>n".$sql."</pre>n".mysql_error());
  60. mysql_query("SET NAMES 'utf8'");
  61. }
  62. ?>
  63.  
  64. <td><input type="hidden" name="bericht[]" value="<?php echo str_replace(["n", "r", "rn", "nn", "x20-x7f", "", "t", "x0B"], '', $cars->message) ; ?>"><?php echo str_replace(["n", "r", "rn", "nn", "x20-x7f", "", "t", "x0B"], '', $cars->message); ?></td>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement