Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.64 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>Edit joke</title>
  4.     </head>
  5.     <body>
  6.         <?php
  7.         $dbCon = @mysql_connect(not for public viewing);
  8.         if (!$dbCon){
  9.             exit("<p>Unable to connect to the database server at this time.</p>");
  10.         }
  11.         if (!@mysql_select_db("ijdb")) {
  12.             exit("<p>Unable to connect to the database at this time.</p>");
  13.         }
  14.         ?>
  15.         <?php
  16.         if(isset($_POST['joketext'])):
  17.             if (empty($_POST['joketext']))
  18.             {
  19.                 exit("<p>You must include some joke text before updating a joke.</p>");
  20.             } else
  21.             {
  22.                 echo "Your amends have been noted.";    
  23.             }
  24.         ?>
  25.         <?php elseif(isset($_GET['id'])):
  26.         $jId = $_GET['id'];
  27.         $gJoke = @mysql_query("select idd,joketext,authorid from joke");
  28.             if (!$gJoke)
  29.             {
  30.                 exit("<p>Unable to retrieve joke at this time.");
  31.             } else
  32.             {
  33.                 while ($grabJokes = mysql_fetch_array($gJoke))
  34.                 {
  35.                     $grabJokeId = $grabJokes['id'];
  36.                     $grabJokeText = $grabJokes['joketext'];
  37.                     $grabJokeAuthor = $grabJokes['authorid'];
  38.                         echo "<p>" . $grabJokeId . " | " . $grabJokeText . " | " . $grabJokeAuthor . "</p>\n\t";
  39.                 }                
  40.             }
  41.         $gAuth = @mysql_query("select id,name from author");
  42.             if (!$gAuth)
  43.             {
  44.                 exit("<p>Unable to retrieve authors at this time.");
  45.             }
  46.             while ($grabAuthors = mysql_fetch_array($gAuth))
  47.             {
  48.                 $grabAuthorId = $grabAuthors['id'];
  49.                 $grabAuthorName = $grabAuthors['name'];
  50.                 echo "<p>" . $grabAuthorId . " | " . $grabAuthorName . "</p>\n\t";
  51.             }
  52.         $gCat = @mysql_query("select id, name from category");
  53.             if (!$gCat)
  54.             {
  55.                 exit("<p>Unable to retrieve categories at this time.</p>");
  56.             }
  57.             while ($grabCategories = mysql_fetch_array($gCat))
  58.             {
  59.                 $grabCatId = $grabCategories['id'];
  60.                 $grabCatName = $grabCategories['name'];
  61.                 echo "<p>" . $grabCatId . " | " . $grabCatName . "</p>\n\t";
  62.             }
  63.         $gJokeCats = @mysql_query("select jokeid, categoryid from jokecategory");    
  64.             if (!$gJokeCats)
  65.             {
  66.                 exit("<p>Unable to retrieve joke categories at this time.</p>");
  67.             }
  68.             while ($grabJokeCatories = mysql_fetch_array($gJokeCats))
  69.             {
  70.                 $grabJokeCatJokeId = $grabJokeCatories['jokeid'];
  71.                 $grabJokeCatCatId = $grabJokeCatories['categoryid'];
  72.                 echo "<p>" . $grabJokeCatJokeId . " | " . $grabJokeCatCatId . "</p>\n\t";
  73.             }
  74.         ?>
  75.         <h1>Edit joke</h1>
  76.             <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  77.                 <p>Edit joke text:&nbsp;</p>
  78.                 <p><textarea cols="45" rows="5" name="joketext"></textarea></p>
  79.                 <p>Edit joke author:</p>
  80.                 <p>
  81.                     <select name="aid">
  82.                         <option value="">test</option>
  83.                     </select>
  84.                 </p>
  85.                 <p>Edit joke categories:</p>
  86.                 <p>
  87.                     <input type="checkbox" name="CATSARRAY" value="" />&nbsp;Hello
  88.                 </p>
  89.                 <p><input type="submit" /></p>
  90.             </form>
  91.         <?php
  92.             endif;
  93.         ?>    
  94.     </body>
  95. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement