oh ok..sorry because i'm newbie to the forum.. so thanks for your help
automatic appear
Collapse
X
-
there is no problem and there is no need to apologize ... just come back when you have specific questions about the correct implementation of the code i showed you ... and post what you have tried so far to get it to work ... the general idea is to let you learn something ... i'm happy to explain everything to you but i should have at least the 'feeling' that you are interested in it and try to understand the code ... vs just waiting to get a copy and paste script ...
kind regardsComment
-
[PHP]<?php require_once('C onnections/mas.php'); ?>
<?php
//initialize the session
if (!isset($_SESSI ON)) {
session_start() ;
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=tru e";
if ((isset($_SERVE R['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("Locatio n: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSI ON)) {
session_start() ;
}
$MM_authorizedU sers = "";
$MM_donotChecka ccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($s trUsers, $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($UserNa me)) {
// 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($User Name, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($User Group, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoT o = "login.php" ;
if (!((isset($_SES SION['MM_Username'])) && (isAuthorized(" ",$MM_authorize dUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_res trictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_S TRING) && strlen($QUERY_S TRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoT o = $MM_restrictGoT o. $MM_qsChar . "accesschec k=" . urlencode($MM_r eferrer);
header("Locatio n: ". $MM_restrictGoT o);
exit;
}
?>
<?php
function GetSQLValueStri ng($theValue, $theType, $theDefinedValu e = "", $theNotDefinedV alue = "")
{
$theValue = (!get_magic_quo tes_gpc()) ? addslashes($the Value) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValu e) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theV alue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValu e : $theNotDefinedV alue;
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)",
GetSQLValueStri ng($_POST['matric'], "text"),
GetSQLValueStri ng($_POST['name'], "text"),
GetSQLValueStri ng($_POST['sessi'], "text"),
GetSQLValueStri ng($_POST['year'], "text"),
GetSQLValueStri ng($_POST['group'], "int"));
$insertSQL2 = sprintf("INSERT INTO medic_registere d_course (matric_no, name, sessi, `year`,`s_code` , `group`) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueStri ng($_POST['matric'], "text"),
GetSQLValueStri ng($_POST['name'], "text"),
GetSQLValueStri ng($_POST['sessi'], "text"),
GetSQLValueStri ng($_POST['year'], "text"),
GetSQLValueStri ng($_POST['s_code'], "text"),
GetSQLValueStri ng($_POST['group'], "int"));
mysql_select_db ($database_mas, $mas);
$Result1 = mysql_query($in sertSQL, $mas) or die(mysql_error ());
$Result2 = mysql_query($in sertSQL2, $mas) or die(mysql_error ());
$saved = true;
}
if ((isset($_POST["name"])) && ($_POST["name"] == "")) {
$colname_rs_mas = "-1";
if (isset($_POST['matric'])) {
$colname_rs_mas = $_POST['matric'];
}
mysql_select_db ($database_mas, $mas);
$query_rs_mas = sprintf("SELECT matric_no, name FROM medic_student WHERE matric_no = %s ORDER BY `id` ASC" , GetSQLValueStri ng($colname_rs_ mas, "text"));
$rs_mas = mysql_query($qu ery_rs_mas, $mas) or die(mysql_error ());
$row_rs_mas = mysql_fetch_ass oc($rs_mas);
$totalRows_rs_m as = mysql_num_rows( $rs_mas);
if ((isset($_POST["s_code"])) && ($_POST["s_code"] == ""))
$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_o ffered WHERE `year` = %s", GetSQLValueStri ng($colname_sco de, "text"));
$scode = mysql_query($qu ery_scode, $mas) or die(mysql_error ());
$row_scode = mysql_fetch_ass oc($scode);
$totalRows_scod e = mysql_num_rows( $scode);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<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.appN ame == 'Netscape') method = "Play";
else {
if (window.MM_WMP == null) {
window.MM_WMP = false;
for(i in sndObj) if (i == "ActiveMovi e") {
window.MM_WMP = true; break;
} }
if (window.MM_WMP) method = "play";
else if (sndObj.FileNam e) method = "run";
} }
if (method) eval(_sndObj+". "+method+"( )");
else window.location = sndFile;
}
//-->
</script>
<script src="clienthint .js">
var xmlHttp
function showHint(str)
{
if (str.length==0)
{
document.getEle mentById("txtHi nt").innerHTML= ""
return
}
xmlHttp=GetXmlH ttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="gethint.ph p"
url=url+"?q="+s tr
url=url+"&sid=" +Math.random()
xmlHttp.onready statechange=sta teChanged
xmlHttp.open("G ET",url,true)
xmlHttp.send(nu ll)
}
function stateChanged()
{
if (xmlHttp.readyS tate==4 || xmlHttp.readySt ate=="complete" )
{
document.getEle mentById("txtHi nt").innerHTML= xmlHttp.respons eText
}
}
function GetXmlHttpObjec t()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest( );
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject(" Msxml2.XMLHTTP" );
}
catch (e)
{
xmlHttp=new ActiveXObject(" Microsoft.XMLHT TP");
}
}
return xmlHttp;
}
</script>
<script src="Scripts/AC_RunActiveCon tent.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="347" align="center" bordercolor="#C CFFCC" class="boxads">
<tr>
<td height="65" colspan="5" bgcolor="#FFFFC C"><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="#FFFFF F" 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="35" bgcolor="#CCFFC C"><div align="right" class="style26" >Matric No</div></td>
<td width="11" bgcolor="#CCFFC C"><div align="center" class="style26" >:</div></td>
<td colspan="3" bgcolor="#CCFFC C"><div align="left">
<input type="text" id="txt1"
onkeyup="showHi nt(this.value)" >
</div></td>
</tr>
<tr>
<td height="33" bgcolor="#CCFFC C"><div align="right" class="style26" >Name</div></td>
<td width="11" bgcolor="#CCFFC C"><div align="center" class="style26" >:</div></td>
<td colspan="3" bgcolor="#CCFFC C"><div align="left">
<p>
<span id="txtHint"></span>
</p>
</div></td>
</tr>
<tr>
<td height="114" bgcolor="#CCFFC C"><div align="right">< span class="style26" >Sessi</span></div></td>
<td bgcolor="#CCFFC C"><div align="center" class="style26" ><strong>:</strong></div></td>
<td bgcolor="#CCFFC C"><div align="left">
<input name="sessi" type="text" class="style26" id="sessi" size="15" maxlength="9" />
</div></td>
<td bgcolor="#CCFFC C"><div align="right">< span class="style26" >Year:</span></div></td>
<td bgcolor="#CCFFC C"><p>
</p>
<p> </p>
<p>
<select name="year" class="style26" id="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="27" bgcolor="#CCFFC C"><div align="right" class="style26" >Group</div></td>
<td bgcolor="#CCFFC C"><div align="center" class="style26" >:</div></td>
<td width="90" bgcolor="#CCFFC C"><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="73" bgcolor="#CCFFC C"><div align="right"></div></td>
<td width="176" bgcolor="#CCFFC C"> </td>
</tr>
<tr>
<td height="24" colspan="5" bgcolor="#CCFFC C"><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_con trolSound('play ','document.CS1 210559072500',' Windows Notify.wav');MM _popupMsg('You\ 're successfully logout from this system...')">Lo gout</a></p>
</div>
<p align="center"> </p>
</div>
<input type="hidden" name="MM_insert " value="form1" />
</form>
<embed name="CS1210559 072500" src="Windows Notify.wav" loop="false" autostart="fals e" hidden="true" width="0" height="0" enablejavascrip t="true"></embed>
</body>
<?php
if ((isset($_POST["block"])) && ($_POST["block"] == "")) {
mysql_free_resu lt($rs_mas);
mysql_free_resu lt($scode);
}
?>
</html>[/PHP]
i had followed all the basic that i had learn it work if i want to search a name.. what should i do if i want to enter matric(number) and appear those name which are in the databse....Comment
-
first: well done :) glad to hear you got it working ... to your question: it seems to be a query-problem ... are all params passed correctly? i think its an insert and is 'name' a db-field? could you show the query and how it is build up in the php?
kind regardsComment
-
[PHP]
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)",
GetSQLValueStri ng($_POST['matric'], "text"),
GetSQLValueStri ng($_POST['name'], "text"),
GetSQLValueStri ng($_POST['sessi'], "text"),
GetSQLValueStri ng($_POST['year'], "text"),
GetSQLValueStri ng($_POST['group'], "int"));
$insertSQL2 = sprintf("INSERT INTO medic_registere d_course (matric_no, name, sessi, `year`,`s_code` , `group`) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueStri ng($_POST['matric'], "text"),
GetSQLValueStri ng($_POST['name'], "text"),
GetSQLValueStri ng($_POST['sessi'], "text"),
GetSQLValueStri ng($_POST['year'], "text"),
GetSQLValueStri ng($_POST['s_code'], "text"),
GetSQLValueStri ng($_POST['group'], "int"));[/PHP]
actually i not done with matric but i tried using drop down menu and use ajax to display infomation.. it woked nicely..!! thanks.. but matric no i now still trying... hehhehe... so sudenlly i got stuck with how to save it.. because it said that s_code can't be null...my registration flow should be like this.. if admin insert data then when they selected one of the drop menu list, it automatic display info about the selected list... but when i click button save, the automatic display(s_code) cannot be insert in database..error :s_code cannot be null?? can you explain what's wrong..???Comment
-
the s_code is automatic display which is connected to the selected year...s_code i'm using ajax.. currently i have 3 pages to do this ajax... then i implement into the original page.. so i had paste my script java to the original page..but the php page i do not implement into the original page..should i paste it same as the ajax script or not??Comment
Comment