Stuck on ticket system

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.

Stuck on ticket system

Postby Connor » Mon Jan 23, 2017 8:23 pm

I've been trying to build a really basic ticket system for hours and i am really stuck on what to do next


The following code is what i have so far, it displays my category and ticket priories from my mysql table, which is great! Buuuttt, i do not have a clue to how i would fill it in (As a user) and then submit it. I've tried loads of things and it just wont insert into my database. Help would be really appreciated, thanks!

(Also, yes i know my coding is horrible, i am extremely bad at it, but it works lol)


Ticket.php
Code: Select all
<?php
include_once 'connect.php';
session_start();

include_once 'logo.php';

?>
 <link href="style.css" rel="stylesheet" type="text/css" />
<div id="login2" div align="center">


<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
?>
</div>



<?php
$bypass = 0;
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
include_once 'runcron.php';
include_once 'statpanel.php';
 ?>
 <div id ="pageinfobar">
 Ticket System
 </div>
 <div id ="locations">
 

 <br />
 
 Type of problem:
  <?php
 mysql_connect('localhost', 'root', '');
mysql_select_db('tutorial');

$sql = "SELECT type FROM tickettype";
$result = mysql_query($sql);

echo "<select name='ticketpriority'>";
while ($row = mysql_fetch_array($result)) {
    echo "<option value='" . $row['type'] ."'>" . $row['type'] ."</option>";
}
echo "</select>";
?>
 <br>
 <br>
 Select importance:
 <?php
 mysql_connect('localhost', 'root', '');
mysql_select_db('tutorial');

$sql = "SELECT level FROM ticketpriority";
$result = mysql_query($sql);

echo "<select name='ticketpriority'>";
while ($row = mysql_fetch_array($result)) {
    echo "<option value='" . $row['level'] ."'>" . $row['level'] ."</option>";
}
echo "</select>";
?>
<br>
 <br>
Describe the problem:
<br>
 <textarea value="" rows="10" cols="50" name="">
 </textarea>
 <br>
 <br>
 
 
</div>
</html>



The code for the ticket system
Code: Select all
Type of problem:
  <?php
 mysql_connect('localhost', 'root', '');
mysql_select_db('tutorial');

$sql = "SELECT type FROM tickettype";
$result = mysql_query($sql);

echo "<select name='ticketpriority'>";
while ($row = mysql_fetch_array($result)) {
    echo "<option value='" . $row['type'] ."'>" . $row['type'] ."</option>";
}
echo "</select>";
?>
 <br>
 <br>
 Select importance:
 <?php
 mysql_connect('localhost', 'root', '');
mysql_select_db('tutorial');

$sql = "SELECT level FROM ticketpriority";
$result = mysql_query($sql);

echo "<select name='ticketpriority'>";
while ($row = mysql_fetch_array($result)) {
    echo "<option value='" . $row['level'] ."'>" . $row['level'] ."</option>";
}
echo "</select>";
?>
<br>
 <br>
Describe the problem:
<br>
 <textarea value="" rows="10" cols="50" name="">
 </textarea>
Connor
 
Posts: 11
Joined: Wed Jan 18, 2017 12:41 am
Has thanked: 1 time
Been thanked: 0 time

Re: Stuck on ticket system

Postby hallsofvallhalla » Wed Jan 25, 2017 10:53 am

User avatar
hallsofvallhalla
Site Admin
 
Posts: 11696
Images: 13
Joined: Wed Apr 22, 2009 6:29 pm
Location: mobile, al
Has thanked: 11 times
Been thanked: 133 times
Blog: View Blog (3)

Re: Stuck on ticket system

Postby KyleMassacre » Fri Apr 21, 2017 8:18 pm

First things first. Get rid of MySQL and look into at a minimum MySQLi. It's 2017 which means your nearing the end of support for that.

Now that is settled, I am going to assume you at least know what $_GET and $_POST is right? $_POST is data that you would normally send through a form. I noticed your code does not include a form which would be a problem. And $_GET is data you get from your URL like what I see in this URL for my response: ?mode=reply&f=71&t=9234. $_GET['mode'] would come out to reply, so on and so forth......

For $_POST the array key ($_POST['key']) would be your input name. That is the data you want to insert into your database.
So without killing your whole learning experience what you need to do is check for the existence of what thy should be typing in, validate it to make sure that's something you want them to enter, and then insert it.

Here are somethings you should look into:
  • isset()
  • array_key_exists()
  • in_array()
  • filter_var()
  • filter_input()
Skype: KyleMassacre
My NWE Modules
User avatar
KyleMassacre
 
Posts: 547
Joined: Wed Nov 27, 2013 7:42 am
Has thanked: 18 times
Been thanked: 34 times


Return to Beginner Help and Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x