Guest User

Untitled

a guest
May 26th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.08 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Post News - ADMINS ONLY</title>
  4. <meta content="text/html; charset=UTF-8" http-equiv="content-type">
  5. <link rel="stylesheet" href="style.css" type="text/css">
  6. </head>
  7. <center><h1>Post News</h1></center>
  8. <hr>
  9.  
  10. <?php
  11. error_reporting (E_ALL ^ E_NOTICE);
  12.  
  13. include('inc/config.php');
  14.  
  15.     if($_POST['post'])
  16.     {
  17.      
  18.      //get data
  19.      $title = $_POST['title'];
  20.      $body = $_POST['body'];
  21.      $date = date("Y-m-d");
  22.      
  23.      //check for existance
  24.      if ($title&&$body)
  25.      {
  26.        
  27.         $dbc = mysql_connect("localhost","agger","n24dgeptbm9c") or die(mysql_error());
  28.         $db_select = mysql_select_db("news") or die(mysql_error());
  29.  
  30.  
  31.         //insert data
  32.         $insert = mysql_query("INSERT INTO news VALUES ('','$title','$body','$date')") or die(mysql_error);
  33.        
  34.         die("<center>Your news has been posted.</center>");
  35.      
  36.      
  37.      }
  38.      else
  39.         echo "<center>Please fill out title and body<p></center>";
  40.      
  41.     }
  42.    
  43.     if($_GET['delete'])
  44.     {
  45.    
  46.     //get data
  47.     $id = $_GET['id'];
  48.    
  49.     //check for existance
  50.     if ($id)
  51.     {
  52.        
  53.         $dbc = mysql_connect("localhost","agger","n24dgeptbm9c") or die(mysql_error());
  54.         $db_select = mysql_select_db("news") or die(mysql_error());
  55.        
  56.         //delete data
  57.         $delete = mysql_query("DELETE FROM news WHERE id='$id'") or die(mysql_error);
  58.        
  59.         echo "<center>The news with ID: $id has been deleted.</center>";
  60.        
  61.        
  62.     }
  63.     else
  64.         echo "<center>Please fill out the ID<p></center>";
  65.    
  66.     }
  67.  
  68. ?>
  69.  
  70. <center>
  71. <form action='post.php' method='POST'>
  72.     Title:<br>
  73.     <input type='test' name='title'><p>
  74.    
  75.     Body:<br>
  76.     <textarea rows='6' cols='35' name='body'></textarea><p>
  77.    
  78.     <input type='submit' name='post' value='Post News'>
  79.     <input type='reset' value='Reset'>
  80. </form>
  81.  
  82. <form action='post.php' method='GET'>
  83.     Delete ID:<br>
  84.     <input type='text' name='id'><p>
  85.    
  86.     <input type='submit' name='delete' value='Delete News'>
  87. </form>
  88.  
  89. <p>If you need to find out what ID to enter, <br>
  90. please go to the Control Panel and look in the MySQL Database, <br>
  91. I'm still working on the feature to lookup at website. <br>
  92. Thank you for your patience and understanding.</p></center>
  93. </html>
Add Comment
Please, Sign In to add comment