[PHP]<?php require_once('Connections/mas.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "login.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["name"])) && ($_POST["name"] != "")) {
$insertSQL = sprintf("INSERT INTO medic_block_reg (matric_no, name, sessi, `year`, `group`) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['matric'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['sessi'], "text"),
GetSQLValueString($_POST['year'], "text"),
GetSQLValueString($_POST['group'], "int"));
$insertSQL2 = sprintf("INSERT INTO medic_registered_course (matric_no, name, sessi, `year`,`s_code`, `group`) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['matric'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['sessi'], "text"),
GetSQLValueString($_POST['year'], "text"),
GetSQLValueString($_POST['s_code'], "text"),
GetSQLValueString($_POST['group'], "int"));
mysql_select_db($database_mas, $mas);
$Result1 = mysql_query($insertSQL, $mas) or die(mysql_error());
$Result2 = mysql_query($insertSQL2, $mas) or die(mysql_error());
$saved = true;
}
if ((isset($_POST["name"])) && ($_POST["name"] == "")) {
$colname_rs_mas = "-1";
if (isset($_POST['matric'])) {
$colname_rs_mas = (get_magic_quotes_gpc()) ? $_POST['matric'] : addslashes($_POST['matric']);
}
mysql_select_db($database_mas, $mas);
$query_rs_mas = sprintf("SELECT matric_no, name FROM medic_student WHERE matric_no = '%s'", $colname_rs_mas);
$rs_mas = mysql_query($query_rs_mas, $mas) or die(mysql_error());
$row_rs_mas = mysql_fetch_assoc($rs_mas);
$totalRows_rs_mas = mysql_num_rows($rs_mas);
$colname_scode = "-1";
if (isset($_POST['year'])) {
$colname_scode = $_POST['year'];
}
mysql_select_db($database_mas, $mas);
$query_scode = sprintf("SELECT `year`, s_code FROM medic_subject_offered WHERE `year` = %s", GetSQLValueString($colname_scode, "text"));
$scode = mysql_query($query_scode, $mas) or die(mysql_error());
$row_scode = mysql_fetch_assoc($scode);
$totalRows_scode = mysql_num_rows($scode);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Block Registration | Medic Assessment System</title>
<link href="css/lgblue.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
.style10 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
.style12 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; }
.style16 {font-size: 18px;
color: #000000;
}
.style8 {font-family: Arial, Helvetica, sans-serif; font-size: 10; }
.style17 {
font-style: italic;
font-size: small;
font-weight: bold;
}
.style18 {
font-size: 14px;
font-weight: bold;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
body,td,th {
color: #996600;
}
.style23 {color: #000000}
.style25 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; }
.style26 {
font-size: 12px;
font-weight: bold;
color: #000000;
}
.style28 {color: #000000; font-weight: bold; }
-->
</style>
<script type="text/JavaScript">
<!--
function MM_popupMsg(msg) { //v1.0
alert(msg);
}
function MM_controlSound(x, _sndObj, sndFile) { //v3.0
var i, method = "", sndObj = eval(_sndObj);
if (sndObj != null) {
if (navigator.appName == 'Netscape') method = "Play";
else {
if (window.MM_WMP == null) {
window.MM_WMP = false;
for(i in sndObj) if (i == "ActiveMovie") {
window.MM_WMP = true; break;
} }
if (window.MM_WMP) method = "play";
else if (sndObj.FileName) method = "run";
} }
if (method) eval(_sndObj+"."+method+"()");
else window.location = sndFile;
}
//-->
</script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body <?php if($saved){echo 'onload="alert(\'One record successfully saved.\');"';}?>>
<form id="form1" name="form1" method="POST">
<div align="center">
<p> </p>
<table width="456" height="458" align="center" bordercolor="#CCFFCC" class="boxads">
<tr>
<td height="46" colspan="5" bgcolor="#FFFFCC"><p align="center" class="style16"> </p>
<p align="center" class="style16 style18">Medic Assessment System </p>
<p align="center" class="style16"> </p></td>
</tr>
<tr>
<td height="29" colspan="5" bgcolor="#FFFFFF" class="style12"><div align="center" class="style10"><span class="style17 style23">Block Registration</span></div>
<span class="style8">
<label></label>
</span><span class="style8">
<label></label>
</span><span class="style1"></span><span class="style1">
<label></label>
</span>
<div align="center" class="style17"></div></td>
</tr>
<tr>
<td width="82" height="39" bgcolor="#CCFFCC"><div align="right" class="style26">Matric No</div></td>
<td width="11" bgcolor="#CCFFCC"><div align="center" class="style26">:</div></td>
<td colspan="3" bgcolor="#CCFFCC"><div align="left">
<input name="matric" type="text" class="style26" id="matric" value="<?php echo $row_rs_mas['matric_no']; ?>" size="15" />
</div></td>
</tr>
<tr>
<td height="38" bgcolor="#CCFFCC"><div align="right" class="style26">Name</div></td>
<td width="11" bgcolor="#CCFFCC"><div align="center" class="style26">:</div></td>
<td colspan="3" bgcolor="#CCFFCC"><div align="left">
<p>
<input name="name" type="text" class="style26" id="name" value="<?php echo $row_rs_mas['name']; ?>" size="50"/>
</p>
</div></td>
</tr>
<tr>
<td height="174" bgcolor="#CCFFCC"><div align="right"><span class="style26">Sessi</span></div></td>
<td bgcolor="#CCFFCC"><div align="center" class="style26"><strong>:</strong></div></td>
<td bgcolor="#CCFFCC"><div align="left">
<input name="sessi" type="text" class="style26" id="sessi" size="15" maxlength="9" />
</div></td>
<td bgcolor="#CCFFCC"><div align="right"><span class="style26">Year:</span></div></td>
<td bgcolor="#CCFFCC"><p>
</p>
<p> </p>
<p>
<select name="year" class="style26" id="year" value="<?php echo $row_scode['year']; ?>" >
<option value="-"> - </option>
<option value="1 block 1"> 1 block 1</option>
<option value="1 block 2"> 1 block 2</option>
<option value="1 block 3"> 1 block 3</option>
<option value="1 block 4"> 1 block 4</option>
<option value=" - "> - </option>
<option value="2 block 1"> 2 block 1</option>
<option value="2 block 2"> 2 block 2</option>
<option value="2 block 3"> 2 block 3</option>
<option value="2 block 4"> 2 block 4</option>
<option value="- "> - </option>
<option value="3 block 1"> 3 block 1</option>
<option value="3 block 2"> 3 block 2</option>
<option value="3 block 3"> 3 block 3</option>
<option value="3 block 4"> 3 block 4</option>
<option value=" - "> - </option>
<option value="4 block 1"> 4 block 1</option>
<option value="4 block 2"> 4 block 2</option>
<option value="4 block 3"> 4 block 3</option>
<option value="4 block 4"> 4 block 4</option>
<option value="4 block 5"> 4 block 5</option>
<option value="4 block 6"> 4 block 6</option>
<option value="4 block 7"> 4 block 7</option>
<option value=" - "> - </option>
<option value="5 block 1"> 5 block 1</option>
<option value="5 block 2"> 5 block 2</option>
<option value="5 block 3"> 5 block 3</option>
<option value="5 block 4"> 5 block 4</option>
<option value="5 block 5"> 5 block 5</option>
</select>
</p>
<p>
<input name="s_code" type="text" class="style26" id="s_code" value="<?php echo $row_scode['s_code']; ?>"/>
</p>
<p> </p></td>
</tr>
<tr>
<td height="29" bgcolor="#CCFFCC"><div align="right" class="style26">Group</div></td>
<td bgcolor="#CCFFCC"><div align="center" class="style26">:</div></td>
<td width="90" bgcolor="#CCFFCC"><div align="left">
<p class="style25">
<select name="group" size="1" class="style26" id="group">
<option value="-">-</option>
<option value="1" >1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</p>
</div></td>
<td width="65" bgcolor="#CCFFCC"><div align="right"></div></td>
<td width="184" bgcolor="#CCFFCC"> </td>
</tr>
<tr>
<td height="32" colspan="5" bgcolor="#CCFFCC"><div align="center">
<input name="save" type="submit" class="style26" id="save" value="Save" />
<input name="Reset" type="reset" class="style26" value="Reset" />
</div>
<div align="center"></div></td>
</tr>
</table>
<div align="center">
<p> </p>
<p class="style10"><a href="reg_main.php">Back</a> | <a href="main.php">Module Menu</a> | <a href="reg_query.php"> View Registered Student</a> | <a href="<?php echo $logoutAction ?>" onclick="MM_controlSound('play','document.CS121055 9072500','Windows Notify.wav');MM_popupMsg('You\'re successfully logout from this system...')">Logout</a></p>
</div>
<p align="center"> </p>
</div>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<embed name="CS1210559072500" src="Windows Notify.wav" loop="false" autostart="false" hidden="true" width="0" height="0" enablejavascript="true"></embed>
</body>
<?php
if ((isset($_POST["block"])) && ($_POST["block"] == "")) {
mysql_free_result($rs_mas);
mysql_free_result($scode);
}
?>
</html>[/PHP]
how can i make when i enter matric no,then automatic appear those name who belong to the matric_no and when i select the drop down menu,automatic appear the data...