Advertisement
Stampe

Untitled

May 10th, 2019
3,344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php  
  2.  
  3.   session_start();
  4.  
  5.   if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
  6.     header("Location: /IT-eksamen/index.php");
  7.     exit;
  8. }
  9.  
  10.   include "include/connect_to_database.php";
  11.  
  12.   if(isset($_POST["opslåg"])){  
  13.   $url = mysqli_real_escape_string($connect, $_POST['url']);
  14.   $tema = mysqli_real_escape_string($connect, $_POST['tema']);
  15.   $comment = mysqli_real_escape_string($connect, $_POST['comment']);
  16.  
  17.   $sql = "INSERT INTO artikle(url, tema, comm) VALUES('$url', '$tema', '$comment')";
  18.  
  19.   if (mysqli_query($connect, $sql)) {
  20.     echo"artikel tilføjet";
  21.   }  
  22.   else{
  23.     echo "der er sket en fejl";
  24.   }
  25. }
  26.  
  27. ?>
  28.  
  29. <!DOCTYPE html>
  30. <html lang="en">
  31. <head>
  32.   <meta charset="UTF-8">
  33.   <title>tilføj artikel</title>
  34. </head>
  35. <body>
  36.   <form method="post" action="add_article_script.php">
  37.     <label>Artikle URL</label>
  38.     <input type="text" name="url">
  39.         <br>
  40.         <label>kommentar</label>
  41.         <br>
  42.         <textarea name="comment" cols="30" rows="10"></textarea>
  43.         <br>
  44.         <input type="radio" name="tema" value="økonomi"> Økonomi
  45.         <br>
  46.         <input type="radio" name="tema" value="debat"> Debat
  47.         <br>
  48.         <input type="radio" name="tema" value="klima"> Klima
  49.         <br>
  50.         <input type="radio" name="tema" value="sundhed"> Sundhed
  51.         <br>
  52.         <input type="radio" name="tema" value="politik"> Politik
  53.         <br>
  54.         <input type="radio" name="tema" value="videnskab"> Videnskab
  55.         <br>
  56.         <input type="radio" name="tema" value="Krimi"> Debat
  57.         <br>
  58.         <input type="radio" name="tema" value="samfund"> Samfund
  59.         <br>
  60.         <input type="radio" name="tema" value="krig"> Krig og terror
  61.         <br>
  62.         <input type="radio" name="tema" value="økonomi"> Udland
  63.         <br>
  64.         <input type="radio" name="tema" value="andet"> andet
  65.         <br>
  66.         <button name="opslåg">Opslåg</button>>
  67.     </form>
  68. </body>
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement