Advertisement
pan7nikt

linki\ignaczak.php

May 16th, 2022 (edited)
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.01 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>linki</title>
  8.  
  9.     <link rel="stylesheet" type="text/css" href="ignaczak.css">
  10. </head>
  11. <body>
  12.     <?php
  13.     $canProceed = true;
  14.     if(empty($_GET['linkToDelete'])){$canProceed = false;}
  15.  
  16.     if($canProceed)
  17.     {
  18.         $conn = mysqli_connect('localhost','root','','linki');
  19.  
  20.         $linkID = $_GET['linkToDelete'];
  21.         mysqli_query($conn, "DELETE FROM `linki` WHERE `linki`.`id` = ".$linkID."");
  22.         echo "Usunięto link o id:".$linkID;
  23.     }
  24.  
  25.     ?>
  26.  
  27.     <?php
  28.     $canProceed = true;
  29.     if(empty($_POST['addButton'])){$canProceed = false;}
  30.     if(empty($_POST['inputText']) && $canProceed){$canProceed = false; echo "Pole tekstowe jest puste";}
  31.  
  32.     if($canProceed)
  33.     {
  34.         $conn = mysqli_connect('localhost','root','','linki');
  35.  
  36.         $link = $_POST['inputText'];
  37.         mysqli_query($conn,"INSERT INTO linki(zawartosc) VALUES ('".$link."')");
  38.         echo "Dodano link o treści:".$link;
  39.         header('Location: ignaczak.php');
  40.     }
  41.     ?>
  42.  
  43.     <?php
  44.     $conn = mysqli_connect('localhost','root','','linki');
  45.  
  46.     $q = mysqli_query($conn, 'SELECT * FROM linki');
  47.  
  48.     echo "<table border='1' width='400'>";
  49.     while($a = mysqli_fetch_array($q))
  50.     {
  51.         echo "<tr><td>";
  52.         echo "<a href='".$a['zawartosc']."'>".$a['zawartosc']."</a>";
  53.         echo "</td><td>";
  54.         echo "<form method='POST' action=''>";
  55.         echo "<a href='ignaczak.php?linkToDelete=".$a['id']."'>Usuń</a><br>";
  56.         echo "<a href='zmien.php?linkID=".$a['id']."'>Zmień</a>";
  57.         echo "</form>";
  58.         echo "";
  59.     }
  60.     echo "</table>";
  61.     ?>
  62.     <form method="POST" action=''>
  63.         Wklej linka: <br>
  64.         <input type="text" name="inputText"><br>
  65.         <button type='submit' name='addButton' value="123">Dodaj</button>
  66.     </form>
  67.  
  68. </body>
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement