Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>linki</title>
- <link rel="stylesheet" type="text/css" href="ignaczak.css">
- </head>
- <body>
- <?php
- $canProceed = true;
- if(empty($_GET['linkToDelete'])){$canProceed = false;}
- if($canProceed)
- {
- $conn = mysqli_connect('localhost','root','','linki');
- $linkID = $_GET['linkToDelete'];
- mysqli_query($conn, "DELETE FROM `linki` WHERE `linki`.`id` = ".$linkID."");
- echo "Usunięto link o id:".$linkID;
- }
- ?>
- <?php
- $canProceed = true;
- if(empty($_POST['addButton'])){$canProceed = false;}
- if(empty($_POST['inputText']) && $canProceed){$canProceed = false; echo "Pole tekstowe jest puste";}
- if($canProceed)
- {
- $conn = mysqli_connect('localhost','root','','linki');
- $link = $_POST['inputText'];
- mysqli_query($conn,"INSERT INTO linki(zawartosc) VALUES ('".$link."')");
- echo "Dodano link o treści:".$link;
- header('Location: ignaczak.php');
- }
- ?>
- <?php
- $conn = mysqli_connect('localhost','root','','linki');
- $q = mysqli_query($conn, 'SELECT * FROM linki');
- echo "<table border='1' width='400'>";
- while($a = mysqli_fetch_array($q))
- {
- echo "<tr><td>";
- echo "<a href='".$a['zawartosc']."'>".$a['zawartosc']."</a>";
- echo "</td><td>";
- echo "<form method='POST' action=''>";
- echo "<a href='ignaczak.php?linkToDelete=".$a['id']."'>Usuń</a><br>";
- echo "<a href='zmien.php?linkID=".$a['id']."'>Zmień</a>";
- echo "</form>";
- echo "";
- }
- echo "</table>";
- ?>
- <form method="POST" action=''>
- Wklej linka: <br>
- <input type="text" name="inputText"><br>
- <button type='submit' name='addButton' value="123">Dodaj</button>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement