selected

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • azura
    New Member
    • Jul 2008
    • 47

    selected

    [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 = (get_magic_quot es_gpc()) ? $_POST['matric'] : addslashes($_PO ST['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($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);

    $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="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>&nbsp;</p>
    <table width="456" height="458" align="center" bordercolor="#C CFFCC" class="boxads">
    <tr>
    <td height="46" colspan="5" bgcolor="#FFFFC C"><p align="center" class="style16" >&nbsp;</p>
    <p align="center" class="style16 style18">Medic Assessment System </p>
    <p align="center" class="style16" >&nbsp;</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="39" 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 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="#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>
    <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="#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>&nbsp;
    </p>
    <p>&nbsp;</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>&nbsp;</p></td>
    </tr>

    <tr>
    <td height="29" 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="65" bgcolor="#CCFFC C"><div align="right"></div></td>
    <td width="184" bgcolor="#CCFFC C">&nbsp;</td>
    </tr>

    <tr>
    <td height="32" 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>&nbsp;</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"> &nbsp;</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]

    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...
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    If the dynamic values are coming from the database then you need to use AJAX.

    Comment

    • azura
      New Member
      • Jul 2008
      • 47

      #3
      how i want to use ajax because i'm very not familiar with ajax.. i'm also new in php..perhaps u can show how it works.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by azura
        how i want to use ajax because i'm very not familiar with ajax.. i'm also new in php..perhaps u can show how it works.
        In short:
        You need to change the data displayed on your page by making a call to the database to retrieve the new data. Traditionally you'd have to provide a submit button and submit the whole page to some server side script which can connect to the database and retrieve the values for you (because Javascript cannot connect to databases). AJAX allows you to call a server side script and retrieve the results without submitting the whole page. The user doesn't have to submit the whole form and wait for the results but they just fire a Javascript event, like for example onChange on a select, and the Javascript function calls the server side script which returns the values to the Javascript function that called it. This function can then use that data to make the page changes.

        Read the AJAX tutorial from w3schools for a more detailed explanation.
        If you get problems implementing it, you can post in the Javascript forum.

        Comment

        Working...