Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "BAUM";
- $password = "HAUS";
- $dbname = "BAUMHAUS";
- print_r($_POST);
- if (isset($_POST['update'])){ // prüfen ob formular übermittelt
- $ID = $_POST['id'];
- if ($ID > 0) {
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn)
- die("Connection failed: " . mysqli_connect_error());
- $id = $_POST['id'];
- $title = $_POST['title'];
- $content = $_POST['content'];
- $img = $_POST['img'];
- $img2 = $_POST['img2'];
- if (filter_var($content, FILTER_VALIDATE_EMAIL)) {
- //entweder '$variable' oder '".$variable."' beides möglich liest du aus einem array aus geht nur die zweite variante
- $sql = "UPDATE texte
- SET
- id='".$id."',
- title='".$title."',
- content='".$content."',
- img='".$img."',
- img2='".$img2."',
- WHERE id='$id' LIMIT 1";
- if (mysqli_query($conn, $sql)) {
- echo "Record updated successfully";
- } else {
- echo "Error updating record: " . mysqli_error($conn);
- }
- } else
- mysqli_close($conn);
- } else {
- echo "ID ERROR";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement