dq1230123 2016-02-14 12:22
浏览 17
已采纳

回复支持门票[关闭]

i'm creating a support ticket system, and now i'm wondering about something, i can't figure out how to make reply system on each ticket. The problem is i don't know how to store replies and load them for each ticket. For example if ticket is like dashboard.php?id=3 to load me only replies from that ticked ID if it has questions in it and like that for other tickets, this is the code i have at the moment:

// this is loading of all user tickets

    if (!isset($_GET['action'])) 
    {
            echo "

            </br><div class='dashboard_info'>Dobrodosli, ovo je vas dashboard. Njegova svrha je pomaganje novim clanovima nase zajednice ali i starijima koji
            imaju poteskoce u snalazenju sa radom User Control Panela. Koriscenjem istog imate razne opcije, ali glavna svrha ovog dela jeste resavanje raznih problema otvaranjem tiketa i slanjem upita.
            Ispod mozete videti vase aktivne tikete ukoliko imate istih, ukoliko vam treba pomoc oko necega mozete poslati tiket klikom na Novi Tiket.</div>

            </br></br></br><center>
            <div class='dataTables'>

                <table>
                <tr>
                      <td CLASS='MYTABLE'>Naslov Tiketa</td>
                      <td CLASS='MYTABLE'>#ID Tiketa</td>
                      <td CLASS='MYTABLE'>Status Tiketa</td>
                      <td CLASS='MYTABLE'>Vrsta Tiketa</td>
                      <td CLASS='MYTABLE'>Datum</td>
                      </tr>

            </center>
";
            $username = $_COOKIE['username'];
            $author = mysqli_real_escape_string($con, $username);
            $query = "SELECT * FROM Dashboard WHERE Postavio = '$author'";
            $result = mysqli_query($con,$query);

            while( $row = mysqli_fetch_array($result,MYSQLI_ASSOC) )
            {
                $ID = clear($row['ID']);
                $Naslov = clear($row['Naslov']);
                $Status = clear($row['Status']);
                $Vrsta = clear($row['Vrsta']);
                $Datum = clear($row['Datum']);

                if($Status == 0) { $statusinfo = "Otvoren"; }
                else if($Status == 1) { $statusinfo = "Zatvoren"; }
                else if($Status == 2) { $statusinfo = "Odgovoren"; }

                echo "

                  <tr CLASS='MYTABLE'>
                    <td CLASS='MYTABLE'><a href='dashboard.php?id=$ID'>$Naslov</a></td>
                    <td CLASS='MYTABLE'><a href='dashboard.php?id=$ID'>#0000$ID</a></td>
                    <td CLASS='MYTABLE'>$statusinfo</td>
                    <td CLASS='MYTABLE'>$Vrsta</td>
                    <td CLASS='MYTABLE'>$Datum</td>
                  <tr>

                  ";    
              }
      }

// this is loading of page with id

  if(isset($_GET['id']))
  {
        $id = clear($_GET['id']); 
        $user =  mysqli_real_escape_string($con, $_COOKIE['username']);
        $query = "SELECT * FROM `dashboard` WHERE `Postavio` = '$username' AND `ID` = '$id'";
        mysqli_query($con, $query);
        $output = mysqli_num_rows($result);

        if($output == 0)
        {
            echo "Vi ste vlasnik ovog ticketa";
            exit();
        }
        else
        {
            echo "Vi niste vlasnik ovog ticketa";
        }
  }

but this doesnt work well even, it should get id from url and compare it to one in database and see if it's made by the user, and if its made by someone else than it should return him to main page.

  • 写回答

1条回答 默认 最新

  • dqz86173 2016-02-14 12:39
    关注

    ...it should get id from url and compare it to one in database and see if it's made by the user, and if its made by someone else than it should return him to main page.

    Look at these statements here,

    $id = clear($_GET['id']); 
    $user =  mysqli_real_escape_string($con, $_COOKIE['username']);
    $query = "SELECT * FROM `dashboard` WHERE `Postavio` = '$username' AND `ID` = '$id'";
                                                                ^ it should be $user
     mysqli_query($con, $query);
    ^ You're not storing the result set.
    

    First store the result set in a variable, and then use mysqli_num_rows() function.

    So your code should be like this:

    // your code
    
    $query = "SELECT * FROM `dashboard` WHERE `Postavio` = '$user' AND `ID` = '$id'";
    $result = mysqli_query($con, $query);
    $output = mysqli_num_rows($result);
    
    if($output){    
        // You are the owner of this ticket
        echo "Vi ste vlasnik ovog ticketa";
    }else{
        // redirect the user to main page
        header("Location: mainpage.php");
        exit();
    }
    
    // your code
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向