note 129971 added to function.pos

From: Date: Fri, 10 Jan 2025 13:39:31 +0000
Subject: note 129971 added to function.pos
Groups: php.notes 
Request: Send a blank email to php-notes+get-221783@lists.php.net to get a copy of this message
<?php require 'connection.php'; if(isset($_POST['username']) && isset($_POST['email'])) { $username = $_POST['username']; $email = $_POST['email']; $stmt = $conn->prepare("INSERT INTO users(username, email, password_hash) VALUES(:username, :email, 'passwort')"); $stmt->bindParam(':username', $username); $stmt->bindParam(':email', $email); $stmt->execute(); } if(isset($_POST['delete'])){ $id = $_GET['resultbutton']; $stmt = $conn->prepare("DELETE FROM users WHERE id = :id"); $stmt->bindParam(':id', $id); $stmt->execute(); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <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>Uebung</title> </head> <body> <div class="container"> <?php $stmt = $conn->prepare("SELECT * FROM users"); $stmt->execute(); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); echo '<table class="table table-striped">'; echo '<tr>'; echo '<th>username</th>'; echo '<th>id</th>'; echo '<th>email</th>'; echo '<th>actions</th>'; echo '</tr>'; foreach($results as $result){ echo '<tr>'; echo '<td>' . $result['username'] . '</td>'; echo '<td>' . $result['id'] . '</td>'; echo '<td>' . $result['email'] . '</td>'; echo '<form method="get">'; echo '<td><button name="resultbutton" value="' . $result['id'] . '" type="submit" class="btn btn-warning" data-bs-toggle="modal" data-bs-target="#updateModal" data-bs-whatever="@getbootstrap">SELECT</button></td>'; echo '</form>'; echo '</tr>'; } echo '</table>'; echo '<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#updateModal" data-bs-whatever="@getbootstrap">Update</button>'; echo '<form method="post"><button class="btn btn-danger" type="submit" name="delete">DELETE</button></form>'; if(isset($_GET['resultbutton'])){ $stmt = $conn->prepare("SELECT email FROM users WHERE id = :id"); $stmt->bindParam(':id', $_GET['resultbutton']); $stmt->execute(); $updated = $stmt->fetch(); } ?> <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal" data-bs-whatever="@getbootstrap">Add</button> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 193.170.70.27) ---- Manual Page -- https://php.net/manual/en/function.pos.php Edit -- https://main.php.net/note/edit/129971 Del: integrated -- https://main.php.net/note/delete/129971/integrated Del: useless -- https://main.php.net/note/delete/129971/useless Del: bad code -- https://main.php.net/note/delete/129971/bad+code Del: spam -- https://main.php.net/note/delete/129971/spam Del: non-english -- https://main.php.net/note/delete/129971/non-english Del: in docs -- https://main.php.net/note/delete/129971/in+docs Del: other reasons-- https://main.php.net/note/delete/129971 Reject -- https://main.php.net/note/reject/129971 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221783) next »