Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="insert.php" method="post" />
- <table id="Wagen">
- <thead>
- <tr>
- <th>Typ</th>
- <th>Kennzeichen</th>
- <th>Bericht</th>
- <th>Fahrer</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $url = ('./cars.xml');
- $xml = simplexml_load_file( urlencode($url), null, true);
- foreach ( $xml->car as $cars ) :?>
- <tr>
- <td><input type="hidden" name="name[]" value="<?php echo $cars->typ; ?>"><?php echo $cars->typ; ?></td>
- <td><input type="hidden" name="kfz-nr[]" value="<?php echo $cars->plate; ?>"><?php echo $cars->plate; ?></td>
- <td><input type="hidden" name="bericht[]" value="<?php echo $cars->message; ?>"><?php echo $cars->message; ?></td>
- <td><input type="hidden" name="fahrer[]" value="<?php echo $cars->driver; ?>"><?php echo $cars->driver; ?></td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
- <input type="submit" name="senden" value="XML speichern" />
- </form>
- <?php
- error_reporting(E_ALL);
- $MYSQL_HOST = 'localhost';
- $MYSQL_USER = 'username';
- $MYSQL_PASS = 'password';
- $MYSQL_DATA = 'database';
- $connid = @mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASS) OR die("Error: ".mysql_error());
- mysql_select_db($MYSQL_DATA) OR die("Error: ".mysql_error());
- if (isset($_POST['senden']))
- {
- $sql =
- "INSERT INTO myTable
- (fahrzeug,
- kennzeichen,
- bericht,
- fahrer
- )
- VALUES
- ('".mysql_real_escape_string(trim($_POST['name']))."',
- '".mysql_real_escape_string(trim($_POST['kfz-nr']))."',
- '".mysql_real_escape_string(trim($_POST['bericht']))."',
- '".mysql_real_escape_string(trim($_POST['fahrer']))."');
- mysql_query($sql) OR die("<pre>n".$sql."</pre>n".mysql_error());
- mysql_query("SET NAMES 'utf8'");
- }
- ?>
- <td><input type="hidden" name="bericht[]" value="<?php echo str_replace(["n", "r", "rn", "nn", "x20-x7f", "