Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How can I input a JavaScript in the below code? Please show an example of where

ID: 3920256 • Letter: H

Question

How can I input a JavaScript in the below code? Please show an example of where the inputted script is located

<html>
    <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="chat.css">  
   <title>Delete Chat Session</title>
</head>
<body >

<?php  
   
    session_start();
    if (!isset($_SESSION['wsuser']))       
    {
    include('tindex.html');
    }
    else
    {   
    // Show the page header
        include('Includes/Header.php');   
        require_once('Includes/Utils.php');       
        require_once('Includes/SQLFunctions.php');       
   
    // Obtain the session to cancel
    $id = check_input($_GET["sid"]);   
    // Make sure input is a number and the session is their's to cancel
    if (is_numeric($id))
    {
       // Make sure this session is owned by the current user
       $schedule = getChatSchedulebyID($id);         
       if ($schedule->getTname() == $_SESSION['wsuser'])
       {      
           $dtext= getGroupCourses($schedule->getGroup()) . "," . $schedule->getThedate() . "," . $schedule->getDay() . "," .
                $schedule->getTStart() . "-" . $schedule->getTend() ;          
           echo "<form name='deleteit' method='POST' action='Deleteit.php'>    ";
            // Display first part of the table
            echo "<h3> Delete Chat Session Confirmation </h3>";
            echo "<p></p>";   
            echo "<div>";
            echo "<table id='myerror'>";
            echo "<tr>";           
            echo "<td>Are you sure you want to permanently delete this session?</td>";
            echo "</tr>";
            echo "<tr>";   
            echo "<td>$dtext</td>";
            echo "</tr>";
            echo "<tr>";   
            echo "<td><input type='submit' value='Yes' name='Delete'>&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' value='No' name='Delete'></td>";
            echo "</tr>";                                          
            echo "<input type='hidden' name='sid' value='$id'>";
            echo "</form>";
            echo "</table>";           
        echo "</div>";       
        echo "<p></p>";                                 
              
       }
       else
    {
        echo "<h3>You can only cancel sessions you own.</h3>";
    }
    }
    else
    {
         echo "Someone might be trying to hack the system";
    }
       
   
}

Explanation / Answer

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="chat.css">  
<title>Delete Chat Session</title>

<!-- You can include your javascript files like below -->
<script type="text/javascript" src="some/path/to/javacript_file.js">

<!-- Also, you can add inline javascript inside <script> tag like below -->
<script>
<!-- YOUR Inline Javascript here -->
</script>
</head>
<body >

<!-- PHP CODE STARTS -->
<?php  

session_start();
if (!isset($_SESSION['wsuser']))
{
include('tindex.html');
}
else
{
// Show the page header
include('Includes/Header.php');
require_once('Includes/Utils.php');
require_once('Includes/SQLFunctions.php');

// Obtain the session to cancel
$id = check_input($_GET["sid"]);
// Make sure input is a number and the session is their's to cancel
if (is_numeric($id))
{
// Make sure this session is owned by the current user
$schedule = getChatSchedulebyID($id);
if ($schedule->getTname() == $_SESSION['wsuser'])
{   
$dtext= getGroupCourses($schedule->getGroup()) . "," . $schedule->getThedate() . "," . $schedule->getDay() . "," .
$schedule->getTStart() . "-" . $schedule->getTend() ;   
echo "<form name='deleteit' method='POST' action='Deleteit.php'> ";
// Display first part of the table
echo "<h3> Delete Chat Session Confirmation </h3>";
echo "<p></p>";
echo "<div>";
echo "<table id='myerror'>";
echo "<tr>";
echo "<td>Are you sure you want to permanently delete this session?</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$dtext</td>";
echo "</tr>";
echo "<tr>";
echo "<td><input type='submit' value='Yes' name='Delete'>&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' value='No' name='Delete'></td>";
echo "</tr>";   
echo "<input type='hidden' name='sid' value='$id'>";
echo "</form>";
echo "</table>";
echo "</div>";
echo "<p></p>";
  
}
else
{
echo "<h3>You can only cancel sessions you own.</h3>";
}
}
else
{
echo "Someone might be trying to hack the system";
}


}
/* The next line for closing of PHP code was missing */
?>
<!-- Also missing <body> and <html> -->
</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote