note 129947 added to reserved.variables.get

From: Date: Fri, 10 Jan 2025 09:50:33 +0000
Subject: note 129947 added to reserved.variables.get
Groups: php.notes 
Request: Send a blank email to php-notes+get-221760@lists.php.net to get a copy of this message
<?php require "connection.php"; //Zum adden von Posts if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['new'])){ if($_POST['title'] && $_POST['content']){ $stmt = $conn->prepare("INSERT INTO posts (user_id, title, content) VALUES (:user_id, :title, :content)"); $stmt->bindParam(':user_id', $user_id); $stmt->bindParam(':title', $title); $stmt->bindParam(':content', $content); $user_id = 1; $title = $_POST['title']; $content = $_POST['content']; $stmt->execute(); } } //Zum löschen if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['detail'])){ $stmt = $conn->prepare("DELETE FROM posts where id = :id"); $stmt->bindParam(':id', $_POST['detail']); $stmt->execute(); } //ZUm updaten if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update'])){ if($_POST['title'] && $_POST['content']){ $stmt = $conn->prepare("UPDATE posts SET title = :title, content = :content WHERE id = :id"); $stmt->bindParam(':title', $title); $stmt->bindParam(':content', $content); $stmt->bindParam(':id', $_GET['detail']); $title = $_POST['title']; $content = $_POST['content']; $stmt->execute(); } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> <title>Test Übung</title> </head> <body class="container-fluid pt-5"> <div class="container"> <?php $stmt = $conn->prepare("SELECT * FROM posts"); $stmt->execute(); $posts = $stmt->fetchAll(PDO::FETCH_ASSOC); echo '<table class="table table-striped">'; echo "<tr>"; echo "<th>id</th>"; echo "<th>user_id</th>"; echo "<th>title</th>" ; echo "<th>content</th>" ; echo "<th>created_at</th>"; echo "</tr>"; foreach ($posts as $post){ echo "<tr>"; echo "<td>" . $post['id'] . "</td>"; echo "<td>" . $post['user_id'] . "</td>"; echo "<td>" . $post['title'] . "</td>"; echo "<td>" . $post['content'] . "</td>"; echo "<td>" . $post['created_at'] . "</td>"; echo '<td><form method="get"><button type="submit" name="detail" value="'. $post['id'] . '" class="btn btn-primary">Details</button></form></td>'; echo '<td><form method="post"><button type="submit" name="detail" value="'. $post['id'] . '" class="btn btn-danger">Delete</button></form></td>'; echo "</tr>"; } echo "</table>"; ?> </div> <div class="container"> <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal" data-bs-whatever="@mdo">Add</button> <form method="post"> <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 193.170.70.27) ---- Manual Page -- https://php.net/manual/en/reserved.variables.get.php Edit -- https://main.php.net/note/edit/129947 Del: integrated -- https://main.php.net/note/delete/129947/integrated Del: useless -- https://main.php.net/note/delete/129947/useless Del: bad code -- https://main.php.net/note/delete/129947/bad+code Del: spam -- https://main.php.net/note/delete/129947/spam Del: non-english -- https://main.php.net/note/delete/129947/non-english Del: in docs -- https://main.php.net/note/delete/129947/in+docs Del: other reasons-- https://main.php.net/note/delete/129947 Reject -- https://main.php.net/note/reject/129947 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221760) next »