0
<?php
//Start a session
if(!isset($_SESSION)){
    session_start();    
}
if($_SESSION['email_address']==""){
    $msg=base64_encode("Please Login");
    header("Location:../../index.php?msg=$msg");
    exit();


}
?>
<?php
require"../db/db_connection.php";

$_GET['email_address']=$_SESSION['email_address'];

date_default_timezone_set("Asia/Colombo");
$stime = date('Y-m-d H:i:s');

$sql = "SELECT c.course_name,c.course_id,su.subject_name,su.subject_id,ex.exam_paper_name,ex.exam_paper_id,ex.date_posted,ex.deadline FROM student s LEFT JOIN course c ON s.course_id=c.course_id LEFT JOIN subject su ON su.course_id=c.course_id LEFT JOIN exam_paper ex ON ex.subject_id=su.subject_id WHERE s.email_address='".$_SESSION['email_address']."' AND ex.status=1";

$query = mysqli_query($con,$sql);
?>
<html>
    <head>
        <meta charset="UTF-8">
        <title>ITech Institute</title>
        <link rel="stylesheet" type="text/css" href="../../css/admin_style.css">
        <meta name="viewport" content="width=device-width,initial-scale: 1.0, user-scalabe=0" />
        <link rel="stylesheet" type="text/css" href="../../font-awesome-4.6.3/font-awesome-4.6.3/css/font-awesome.css">

         <script src="../../js/jquery.min.js"></script>
        <script src="../../js/admin.js"></script>
         <!-- For nice scroll start-->
<script src="../../js/jquery.nicescroll.js"></script>
<script src="../../js/style.js"></script> 
<!-- nice scroll end-->
<!-- clock start-->
<script src="../../js/clock.js"></script>

    </head>
    <body>
     <?php
    include("../../include/internal_header.php");
?>
   <!-- <div id="header">

        <div class="logo"> <a href="#">Admin<span> Page</span></a></div>
    </div>-->
    <a class="mobile" href="#">MENU</a>

    <div id="container">
        <div class="sidebar">
            <ul id="accordion" class="accordion" style="margin:0; padding:0;">
   <li>
    <div class="link"><i class="fa fa-dashboard"></i><a href="student_dashboard.php">Dashboard</a></div>
  </li>
  <li>
    <div class="link"><i class="fa fa-globe"></i><a href="profile.php">Profile</a></div>
  </li>
  <li>
    <div class="link"><i class="fa fa-globe"></i><a href="view_course.php">View Courses</a></div>

  </li>
  <li>
    <div class="link"><i class="fa fa-globe"></i><a href="view_subject.php">View Subjects</a></div>

  </li>
  <li>
    <div class="link"><i class="fa fa-globe"></i><a href="view_exam.php">Exam</a></div>
  </li>
  <li>
    <div class="link"><i class="fa fa-globe"></i><a href="view_result.php">View Result</a></div>
  </li>
  <li>
    <div class="link"><i class="fa fa-globe"></i><a href="signout.php">Log Out</a></div>
  </li>
  <li>
    <div class="link"><form name="clock"><font color="white"><i class="fa fa-clock-o"></i>Time: <br></font>&nbsp;<input style="width:150px;" type="submit" class="trans" name="face" value="">
    </form>
    </div>
    </li>
</ul>

 </div><!--sidebar-->


        <div class="content">
            <div class="content_heading">
                <p>View Exams</p>
            </div><!--content_heading-->
       <div class="div1">
 <!--table start-->

<table>
<tr>
<td>Course Name</td>
<td>Subject Name</td>
<td>Exam Paper Name </td>
<td>Data Posted Name</td>
<td>Dead Line</td>
<td>Start Exam</td>

</tr>


<tr><?php while($row = mysqli_fetch_array($query)){ ?>
<td><?php echo $row["course_name"]; ?></td>
<td><?php echo $row["subject_name"]; ?></td>
<td><?php echo $row["exam_paper_name"]; ?></td>
<td><?php echo $row["date_posted"]; ?></td>
<td><?php echo $row["deadline"]; ?></td>
<td>
<a  target="_blank" title="Start Exam" href="start_exam_paper.php?stime=<?php echo $stime;?>&exid=<?php echo $row['exam_paper_id'];?>&cid=<?php echo $row['course_id'];?>&suid=<?php echo $row['subject_id'];?>"style="visibility:<?php echo $_SESSION["Visibility"]; ?>">
    <button id="btn-st">
        <i class="fa fa-edit"></i>&nbsp;Start Exam 
    </button> 
</a>

</td>
</tr>
<?php }?>


</table>
</div><!--div1-->
</div>
</div><!--div1-->


        </div><!--content-->
    </div><!--container--> 
    </body>
</html>

this is my code i need to disable the Start Exam button after the click.and student can't re-logging and click the button again, my system in examination system. i use the js but it's not work properly. so i need to validate to php

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • SQL injection!!! – Rotimi Mar 24 '17 at 11:12
  • @PhpDev have you ever done SQL injection or seen except studying?? – M A SIDDIQUI Mar 24 '17 at 11:13
  • safe the "start exam click" with time and a special user token inside the session. And then check via session if these values are already set or not, but you should really check your code for SQL injection and you might should rework your Jquery – Ann-Sophie Angermüller Mar 24 '17 at 11:14
  • i use the js in one or two times but it's not work, and one time i hide the button but after re logging that button show – Dulanga Gananath Weerasuriya Mar 24 '17 at 11:18
  • 2
    Your script is at risk of [SQL Injection Attack](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) Have a look at what happened to [Little Bobby Tables](http://bobby-tables.com/) Even [if you are escaping inputs, its not safe!](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) Use [prepared parameterized statements](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) – RiggsFolly Mar 24 '17 at 11:21

1 Answers1

0

You can save student details into session after login. if session has value then use this condition in you php file:

if(!empty($_SESSION)){
     echo "";    // Don't put here your login button.
  }else{
      echo " Your login button";   // Put here your login button.
  }
Karnail Singh
  • 116
  • 1
  • 12