Advertisement
pan7nikt

linki\zmien.php

May 19th, 2022
1,310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 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>zmiana linku</title>
  8. </head>
  9. <body>
  10.  
  11.     <?php
  12.     $canProceed = true;
  13.  
  14.     if(empty($_GET['linkID'])){$canProceed = false;}
  15.  
  16.     if($canProceed)
  17.     {
  18.         $linkID = $_GET['linkID'];
  19.         $conn = mysqli_connect('localhost','root','','linki');
  20.  
  21.         $q = mysqli_query($conn,"SELECT * FROM linki WHERE id=".$linkID.";");
  22.         $a = mysqli_fetch_array($q);
  23.  
  24.         echo "<form method='POST' action=''>";
  25.         echo "<input name='newLink' type='text' value='".$a['zawartosc']."'>";
  26.         echo "<button type='submit'>Potwierdź zmiany</button>";
  27.         echo "</form>";
  28.     }
  29.  
  30.     if(empty($_POST['newLink'])){$canProceed = false;}
  31.  
  32.     if($canProceed)
  33.     {
  34.         $newLink = $_POST['newLink'];
  35.  
  36.         $q = mysqli_query($conn,"UPDATE `linki` SET `zawartosc` = '".$newLink."' WHERE `linki`.`id` = ".$linkID.";");
  37.  
  38.         echo "Zmieniono link o ID: ".$linkID." na: ".$newLink;
  39.         header('Location: ignaczak.php');
  40.     }
  41.  
  42.     ?>
  43. </body>
  44. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement