Sindbad~EG File Manager

Current Path : /usr/home/beeson/public_html/helpwithmath/WebGrades/
Upload File :
Current File : /usr/home/beeson/public_html/helpwithmath/WebGrades/WebGradesNewClass.php

<?php 
 
 // This page is the response page to a form in WebGradesNewClassForm.html.  It 
 // allows the creation of a new class in the WebGrades database, 
 // after which students in that class can enroll in WebGrades.

session_start(); 
require_once('DB.php');
require_once('../queryWebGrades.php');

$ClassName = $_POST['ClassName'];
$Teacher = $_POST['Teacher'];
$School = $_POST['School'];
$StartDate = $_POST['StartDate'];
$EndDate = $_POST['EndDate'];

   
// The following code prevents accessing this page without supplying the required data

if(!isset($ClassName)) die();
if(!isset($Teacher))  $Teacher = "Dr. Beeson";  // see CheckEnrollment.php, can't get this to be passed yet
if(!isset($School)) die();
if(!isset($StartDate)) die();
$success = 0;

   
function newclass(  $ClassName, $Teacher,   $School, $StartDate, $EndDate) 
// Store the given data in the webgrades database
{ global $success; 
// first see if the class is already there.
  $sql = "SELECT * FROM `Classes` WHERE ClassName='$ClassName'  AND School='$School' AND StartDate='$StartDate' AND Teacher = '$Teacher';";
  $r = QueryWebGrades($sql);
  if($r->fetchRow() != NULL)
      return "Class already exists. You cannot add an existing class.";
  $sql = "INSERT INTO `Classes` (ClassName, Teacher, School, StartDate, EndDate) VALUES ('$ClassName', '$Teacher','$School', '$StartDate', '$EndDate');";
  QueryWebGrades($sql);
  // check if it worked.
   $sql = "SELECT * FROM `Classes` WHERE ClassName='$ClassName'  AND School='$School' AND StartDate='$StartDate' AND Teacher = '$Teacher' AND EndDate='$EndDate';";
   $r = QueryWebGrades($sql);
  if($r->fetchRow() != NULL)
      return "Your class was successfully added.";
  return "Error, your class was not added, for unknown reasons.  This can't happen.";

}  
?>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Creating a New Class in WebGrades</title>
</head>

<body>
<?php 
 $message =   newclass( $ClassName, $Teacher, $School, $StartDate, $EndDate);
 echo "<p>$message</p>";
 echo "$ClassName x<br>";
  echo "$Teacher x<br>";
   echo "$StartDate x<br>";
 ?>
 
</body>
</html>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists