Advertisement
Tyler_

bug report

May 9th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <?php
  2.     /*  CREATE TABLE `bug_reports`
  3.         (
  4.             `user` VARCHAR(24),
  5.             `bug` TEXT(1024),
  6.             `time` VARCHAR(24)
  7.         )
  8.     */
  9.  
  10.     $user = getUserFromSession($_SESSION['session_id']);
  11.     $bug = $_POST['bug'];
  12.     $time = date("Y-m-d");
  13.     $form = $_POST['form'];
  14.  
  15.     if (!strlen($bug) && $form)
  16.     {
  17.         $form = 2;
  18.         echo "<font color='red'>You did not enter a bug in the box provided. Please try again.</font><br>";
  19.     }
  20.  
  21.     if (!strlen($user) && $form)
  22.     {
  23.         $form = 2;
  24.         echo "<font color='red'>You are not currently logged in. Please log in and try again.</font><br>";
  25.     }
  26.  
  27.     if ($form == 2)
  28.     {
  29.         $query = "INSERT INTO `bug_reports` (`user`,`bug`,`time`) VALUES('$user','$bug','$time')");
  30.         $result = mysql_query($query);
  31.         if (mysql_affected_rows($result))
  32.         {
  33.             echo "<font color='green'>Bug report sent successfully</font><br>";
  34.             mysql_free_result($result);
  35.             break;
  36.         }
  37.         else
  38.         {
  39.             echo "<font color='red'>Bug report went wrong. Try again.</font><br>";
  40.             mysql_free_result($result);
  41.             break;
  42.         }
  43.     }
  44.  
  45.     echo "<form action='bug.php' method='post'>";
  46.         echo "<input type='hidden' name='form' value='1'>"; // add a hidden value to declare whether they have submitted the form yet or not
  47.         echo "<textarea cols='25' rows='10'>Write the bug here with as much description as possible.</textarea>";
  48.         echo "<input type='submit' value='Submit bug'>";
  49.     echo "</form>";
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement