SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Kuching, Sarawak
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Php undefined index error

    I had dynamic webpages designed with php and sql. I move my root files from C:\wamp\www\Mentor Mentee System\ to another PC and redo the connection. But, I am having undefined index error in C:\wamp\www\Mentor Mentee System\index.php on line 205. How should I deal with this error?

    My scripts as below:

    Code:
    <?php require_once('Connections/connection.php'); ?>
    <?php include('Connections/myconnection.php');?>
    
    
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
    if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }
    
    
    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
    }
    }
    ?>
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
    session_start();
    }
    
    
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
    $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    }
    
    
    if (isset($_POST['admin_id'])) {
    $loginUsername=$_POST['admin_id'];
    $password=$_POST['password'];
    $MM_fldUserAuthorization = "student_id";
    $MM_redirectLoginSuccess = "manage_student.php?student_id=$loginUsername";
    $MM_redirectLoginFailed = "index.php?error=e";
    $MM_redirecttoReferrer = true;
    mysql_select_db($database_connection, $connection);
        
    $LoginRS__query=sprintf("SELECT student_id, student_pass, student_id FROM student WHERE student_id=%s AND student_pass=%s",
    GetSQLValueString($loginUsername, "int"), GetSQLValueString($password, "text")); 
    
    
    $LoginRS = mysql_query($LoginRS__query, $connection) or die(mysql_error());
    $loginFoundUser = mysql_num_rows($LoginRS);
    if ($loginFoundUser) {
    
    
    $loginStrGroup = mysql_result($LoginRS,0,'student_id');
    
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;     
    
    
    if (isset($_SESSION['PrevUrl']) && true) {
    $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];    
    }
    header("Location: " . $MM_redirectLoginSuccess );
    }
    else {
    header("Location: ". $MM_redirectLoginFailed );
    }
    }
    ?>
    <!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=utf-8" />
    <title>FENG Mentor Mentee System</title>
    
    
    <style type="text/css">
    </style>
    
    
    <script type="text/javascript" src="image/swfobject.js"></script>
    <script type="text/javascript" src="image/prototype.js"></script>
    <script type="text/javascript" src="image/scriptaculous.js"></script>
    <script type="text/javascript" src="image/effects.js"></script>
    <script type="text/javascript" src="image/lightbox.js"></script>
    <link rel="stylesheet" href="image/lightbox.css" type="text/css" media="screen">
    
    
    <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
    <link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" />
    <link rel="shortcut icon" href="image/clogo.PNG" type="image/x-icon"/>
    
    
    </head>
    
    
    <body background="image/background.jpg">
    <!-- BodyFrame -->
    <table width="1250" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
    
    
    <!-- Banner -->
    <tr>
    <td width="1250" height="120" align="center" valign="top" background="image/banner.jpg" bgcolor="#999999"></td>
    </tr>
    <!-- Banner -->
    
    
    <!-- TopBorder -->
    <tr>
    <td height="23" bgcolor="#408080"></td>
    </tr>
    <!-- TopBorder -->
    
    
    <!--BodyMenuOut-->
    <tr>
    <td>
    <table width="1250" align="center" valign="top">
    
    
        <!--BodyMenuIn-->
        <tr>
    
    
            <!--BodyMenuLeft-->
            <td width="410" align="center" valign="top">                            
    <table width="420" border="0" cellpadding="0" cellspacing="0">
        <tr>
    <td width="420" height="18">
    <!--BorderGray-->
    <table width="420" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="420" height="23" bgcolor="#999999" style="font-size: 12px"></td>
    </tr>
    </table>
    <!--BorderGray-->
    </td>
                    <tr><!--XXX-->
    <td width="420" align="left" valign="top">
        <form action="<?php echo $loginFormAction; ?>" method="POST" name="frmLogin" id="frmLogin" style="font-size: 12px;">
    <table width="420" border="0" align="center" cellpadding="0" cellspacing="0">
                                <!--StudentLecturer-->
    <tr>
    <td height="32" colspan="4">
    <strong>&nbsp;
    [<a href="index.php" style="color:#004080; font-size: 13px">Student</a>] 
    [<a href="login_lecturer.php" style="color:#004080; font-size: 13px">Lecturer</a>]</strong></td>
            </tr>
                                <!--StudentLecturer-->
                                <!--LoginStudent-->
    <tr bgcolor="#408080">
    <td height="23" colspan="4"> <strong style="color: #FFF; font-size: 13px;">&nbsp;&nbsp;&nbsp;Login Student</strong></td>
    </tr>
                                <!--LoginStudent-->
    <tr>
    <td height="6" colspan="4"></td>
    </tr>
                                <!--UserID-->
    <tr bgcolor="#D6F5F5">
    <td width="40" height="23"></td>
    <td width="75" height="23"><strong style="color: #004080; font-size: 12px;">UserID</strong></td>
    <td width="15"><strong style="color: #004080; font-size: 12px;">/strong></td>
    <td width="290" style="font-size: 12px">
    <span id="sprytextfield1">
    <label>
    <input style="font-family: Verdana, Geneva, sans-serif; font-size: 11px; color: #009;" name="admin_id" type="text" id="admin_id" size="11" maxlength="100" />
    </label>
    </span>
    </td>
    </tr>
                                <!--UserID-->
                                <!--Password-->
    <tr bgcolor="#FFFFCC">
    <td width="40" height="23"></td>
    <td width="75" height="23"><strong style="color: #004080; font-size: 12px;">Password</strong></td>
    <td width="15" height="23"><strong style="color: #004080; font-size: 12px;">/strong></td>
    <td width="290" style="font-size: 12px">
    <span id="sprypassword1">
    <label>
    <input style="font-family: Verdana, Geneva, sans-serif; font-size: 11px; color: #009;" name="password" type="password" id="password" size="11" maxlength="100" />
    </label>
    </span>
    </td>
    </tr>
                                <!--Password-->
    <tr>
    <td height="6" colspan="4"></td>
    </tr>
                                <!--LoginButton-->
    <tr>
    <td height="21" colspan="3"></td>
    <td width="290" height="21">
    <label>
        <input type="image" src="image/button_login.gif" name="Login" id="Login" value="Login" />
    </label>
    </td>
    </tr>
                                <!--LoginButton-->
    </table>
    
    
                            <!--InvalidUser-->
    <?php if($_REQUEST['error']==e){?>
    <table width="300" border="0" align="left" cellpadding="0" cellspacing="0">
    <tr>
    <td width="300" height="5" colspan="2"></td>
    </tr>
    <tr>
    <td width="40" height="3"></td>
    <td width="260" height="3" bgcolor="#FFCCCC"></td>
    </tr>
    <tr>
    <td width="40" height="20"></td>
    <td width="260" height="20" bgcolor="#FFCCCC" style="color:#C00; text-align:center; font-weight: bold; font-size: 12px;">Invalid UserID or Password !!!</td>
    </tr>
    <tr>
    <td width="40" height="20"></td>
    <td width="260" height="20" bgcolor="#FFCCCC" style="color:#C00; text-align:center; font-weight: bold; font-size: 12px;">Please Try Again !!!</td>
    </tr>
    <tr>
    <td width="40" height="3"></td>
    <td width="260" height="3" bgcolor="#FFCCCC"></td>
    </tr>
    </table>
                            <!--InvalidUser-->
                            <?php }?>
        </form>
                        </td>
        </tr>
    </table>
            </td>
            <!--BodyMenuLeft-->
    
    
            <!--BodyMenuRight-->
            <td width="828" align="center" valign="top">
    <table width="818" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr bgcolor="#999999">
    <td height="23" colspan="3" align="center"><strong style="font-size: 14px; color: #FFF;">Student Session</strong></td>
    </tr>
    <tr>
    <td height="32" colspan="3"></td>
    </tr>
    <tr bgcolor="#D6F5F5">
    <td width="37" rowspan="3"></td>
    <td width="744" height="6"></td>
    <td width="37" rowspan="3"></td>
    </tr>
    <tr align="center" bgcolor="#D6F5F5" >
    <td width="744"><p class="style32" align="left"><span style="color: #000; font-weight: bold; font-size: 12px;font-weight: bold; color: #004080;">Welcome to Mentor Mentee System - Student Session</span></span>.</p>
    <p style="font-size: 12px; text-align: justify; font-weight: normal; color: #004080;">In this session, student's can fully access their own personal information and make necessary amendments when needed.</p>
    <p style="font-size: 12px; text-align: justify; font-weight: normal;color: #004080;">At the same time, student's can view their academic information and academic progress along with a bar graph for each academic session that they have completed thus far.</p></td>
    </tr>
    <tr bgcolor="#D6F5F5">
    <td width="744" height="6"></td>
    </tr>
    <tr>
    <td height="32" colspan="3"></td>
    </tr>
    </table>
            </td>
            <!--BodyMenuRight-->
    
    
        </tr>
        <!--BodyMenuIn-->
    
    
    </table>
    </td>
    </tr>
    <!--BodyMenuOut-->
    
    
    </table>
    <!-- BodyFrame -->
    
    
    <!-- BottomBorder -->
    <table width="1250" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr bgcolor="#999999">
    <td width="1250" height="23"></td>
        </tr>
    <tr bgcolor="#408080">
    <td width="1250" height="23"></td>
    </tr>
    <tr>
    <td width="1250" height="6"></td>
    </tr>
        <tr>
    <td width="1250" height="500" align="center" valign="top" style="font-size: 10px;">
    <strong style="font-style: italic; color: #004080; font-weight: bold;">Faculty of Engineering Mentor Mentee</strong>
    <strong><a href="login_admin.php" style="font-style: italic; color:#004080; font-weight: bold;">System</a></strong>
    <strong style="font-style: italic; color: #004080; font-weight: bold;"> @ Copyright 2011</strong><br />
    <strong style="font-style: italic; color: #004080; font-weight: bold;">Designed by Nor Fadzillah Hana Sabtu</strong><br />
    <strong style="font-style: italic; color: #004080; font-weight: bold;">Revised by Dr Mohd Saufee Muhammad</strong></td>
    </tr>
    </table>
    <!-- BottomBorder -->
    
    
    <script type="text/javascript">
    <!--
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1");
    //-->
    </script>
    </body>
    </html>
    Last edited by spikeZ; Nov 3, 2011 at 08:30.

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Hi and welcome to SitePoint

    OK if this is line 205
    <?php if($_REQUEST['error']==e){?>

    then there could be a couple of errors.
    If $_REQUEST['error'] has NOT BEEN SET then an error will be displayed
    if e is not a function then an error will be displayed.

    Try
    Code:
    <?php if(isset($_REQUEST['error']) && ($_REQUEST['error']== 'e')) { ?>
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Kuching, Sarawak
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <?php if(isset($_REQUEST['error']) && ($_REQUEST['error']== 'e')) { ?>
    Many thanks, it works. =)

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Kuching, Sarawak
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am also having the undefined index error on the line of 311 which I have highlighted it below.

    PHP Code:
    <?php require_once('Connections/connection.php'); ?>
    <?php 
    include('Connections/myconnection.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_admin.php";
    if (
    $logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
    }
    }

    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_admin.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;
    }

    if (!
    function_exists("GetSQLValueString")) {
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
    if (
    PHP_VERSION 6) {
    $theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }

    $theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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['student_idII'])) && ($_POST['student_idII'] != "")) {
    $deleteSQL sprintf("DELETE FROM student WHERE student_id=%s",
    GetSQLValueString($_POST['student_idII'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($deleteSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "updatetranscript")) {
    $updateSQL sprintf("UPDATE transcript SET student_id=%s, course_type=%s, academic_year=%s, transcript_update=%s, course_id=%s, admin_id=%s, grade_id=%s WHERE transcript_id=%s",
    GetSQLValueString($_POST['student_id'], "text"),
    GetSQLValueString($_POST['course_type'], "text"),
    GetSQLValueString($_POST['academic_year'], "text"),
    GetSQLValueString($_POST['transcript_update'], "text"),
    GetSQLValueString($_POST['course_id'], "text"),
    GetSQLValueString($_POST['admin_id'], "text"),
    GetSQLValueString($_POST['grade_id'], "text"),
    GetSQLValueString($_POST['transcript_id'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($updateSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "frmyear52")) {
    $updateSQL sprintf("UPDATE student SET ch52=%s, gpa52=%s, cgpa52=%s WHERE student_id=%s",
    GetSQLValueString($_POST['ch52'], "text"),
    GetSQLValueString($_POST['gpa52'], "text"),
    GetSQLValueString($_POST['cgpa52'], "text"),
    GetSQLValueString($_POST['student_id'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($updateSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "frmyear51")) {
    $updateSQL sprintf("UPDATE student SET ch51=%s, gpa51=%s, cgpa51=%s WHERE student_id=%s",
    GetSQLValueString($_POST['ch51'], "text"),
    GetSQLValueString($_POST['gpa51'], "text"),
    GetSQLValueString($_POST['cgpa51'], "text"),
    GetSQLValueString($_POST['student_id'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($updateSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "frmyear42")) {
    $updateSQL sprintf("UPDATE student SET ch42=%s, gpa42=%s, cgpa42=%s WHERE student_id=%s",
    GetSQLValueString($_POST['ch42'], "text"),
    GetSQLValueString($_POST['gpa42'], "text"),
    GetSQLValueString($_POST['cgpa42'], "text"),
    GetSQLValueString($_POST['student_id'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($updateSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "frmyear41")) {
    $updateSQL sprintf("UPDATE student SET ch41=%s, gpa41=%s, cgpa41=%s WHERE student_id=%s",
    GetSQLValueString($_POST['ch41'], "text"),
    GetSQLValueString($_POST['gpa41'], "text"),
    GetSQLValueString($_POST['cgpa41'], "text"),
    GetSQLValueString($_POST['student_id'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($updateSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "frmyear32")) {
    $updateSQL sprintf("UPDATE student SET ch32=%s, gpa32=%s, cgpa32=%s WHERE student_id=%s",
    GetSQLValueString($_POST['ch32'], "text"),
    GetSQLValueString($_POST['gpa32'], "text"),
    GetSQLValueString($_POST['cgpa32'], "text"),
    GetSQLValueString($_POST['student_id'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($updateSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "frmyear31")) {
    $updateSQL sprintf("UPDATE student SET ch31=%s, gpa31=%s, cgpa31=%s WHERE student_id=%s",
    GetSQLValueString($_POST['ch31'], "text"),
    GetSQLValueString($_POST['gpa31'], "text"),
    GetSQLValueString($_POST['cgpa31'], "text"),
    GetSQLValueString($_POST['student_id'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($updateSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "frmyear22")) {
    $updateSQL sprintf("UPDATE student SET ch22=%s, gpa22=%s, cgpa22=%s WHERE student_id=%s",
    GetSQLValueString($_POST['ch22'], "text"),
    GetSQLValueString($_POST['gpa22'], "text"),
    GetSQLValueString($_POST['cgpa22'], "text"),
    GetSQLValueString($_POST['student_id'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($updateSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "frmyear21")) {
    $updateSQL sprintf("UPDATE student SET ch21=%s, gpa21=%s, cgpa21=%s WHERE student_id=%s",
    GetSQLValueString($_POST['ch21'], "text"),
    GetSQLValueString($_POST['gpa21'], "text"),
    GetSQLValueString($_POST['cgpa21'], "text"),
    GetSQLValueString($_POST['student_id'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($updateSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "frmyear12")) {
    $updateSQL sprintf("UPDATE student SET ch12=%s, gpa12=%s, cgpa12=%s WHERE student_id=%s",
    GetSQLValueString($_POST['ch12'], "text"),
    GetSQLValueString($_POST['gpa12'], "text"),
    GetSQLValueString($_POST['cgpa12'], "text"),
    GetSQLValueString($_POST['student_id'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($updateSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "frmyear11")) {
    $updateSQL sprintf("UPDATE student SET ch11=%s, gpa11=%s, cgpa11=%s WHERE student_id=%s",
    GetSQLValueString($_POST['ch11'], "text"),
    GetSQLValueString($_POST['gpa11'], "text"),
    GetSQLValueString($_POST['cgpa11'], "text"),
    GetSQLValueString($_POST['student_id'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($updateSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmaddtranscript")) {
    $insertSQL sprintf("INSERT INTO transcript (student_id, course_type, academic_year, transcript_update, course_id, admin_id, grade_id) VALUES (%s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['student_id'], "text"),
    GetSQLValueString($_POST['course_type'], "text"),
    GetSQLValueString($_POST['academic_year'], "text"),
    GetSQLValueString($_POST['transcript_update'], "text"),
    GetSQLValueString($_POST['course_id'], "text"),
    GetSQLValueString($_POST['admin_id'], "text"),
    GetSQLValueString($_POST['grade_id'], "text"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($insertSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmaddcourse")) {
    $insertSQL sprintf("INSERT INTO course (course_id, admin_id, course_name, course_update) VALUES (%s, %s, %s, %s)",
    GetSQLValueString($_POST['course_id'], "text"),
    GetSQLValueString($_POST['admin_id'], "text"),
    GetSQLValueString($_POST['course_name'], "text"),
    GetSQLValueString($_POST['course_update'], "text"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($insertSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "frmedituser")) {
    $updateSQL sprintf("UPDATE student SET student_name=%s, student_ic=%s, student_gender=%s, student_race=%s, student_religion=%s, student_address_c=%s, student_email=%s, `year`=%s, year_intake=%s, program=%s, student_contact=%s, student_address=%s, lect_id=%s, medical=%s, medical_name=%s, medical_relation=%s, medical_contact=%s, medical_address=%s, admin_id=%s, admin_update=%s WHERE student_id=%s",
    GetSQLValueString($_POST['student_name'], "text"),
    GetSQLValueString($_POST['student_ic'], "text"),
    GetSQLValueString($_POST['student_gender'], "text"),
    GetSQLValueString($_POST['student_race'], "text"),
    GetSQLValueString($_POST['student_religion'], "text"),
    GetSQLValueString($_POST['student_address_c'], "text"),
    GetSQLValueString($_POST['student_email'], "text"),
    GetSQLValueString($_POST['year'], "int"),
    GetSQLValueString($_POST['year_intake'], "text"),
    GetSQLValueString($_POST['program'], "text"),
    GetSQLValueString($_POST['student_contact'], "int"),
    GetSQLValueString($_POST['student_address'], "text"),
    GetSQLValueString($_POST['lect_id'], "text"),
    GetSQLValueString($_POST['medical'], "text"),
    GetSQLValueString($_POST['medical_name'], "text"),
    GetSQLValueString($_POST['medical_relation'], "text"),
    GetSQLValueString($_POST['medical_contact'], "text"),
    GetSQLValueString($_POST['medical_address'], "text"),
    GetSQLValueString($_POST['admin_id'], "text"),
    GetSQLValueString($_POST['admin_update'], "text"),
    GetSQLValueString($_POST['student_id'], "int"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($updateSQL$connection) or die(mysql_error());
    }

    if ((isset(
    $_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmaddlect1")) {
    $insertSQL sprintf("INSERT INTO lecturer (lect_id, lect_password, lect_name, lect_register, dept) VALUES (%s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['lect_id'], "text"),
    GetSQLValueString($_POST['lect_password'], "text"),
    GetSQLValueString($_POST['lect_name'], "text"),
    GetSQLValueString($_POST['lect_register'], "text"),
    GetSQLValueString($_POST['dept'], "text"));

    mysql_select_db($database_connection$connection);
    $Result1 mysql_query($insertSQL$connection) or die(mysql_error());
    }

    mysql_select_db($database_connection$connection);
    $query_lecturer "SELECT * FROM lecturer WHERE dept='$_REQUEST[dept]'";
    $lecturer mysql_query($query_lecturer$connection) or die(mysql_error());
    $row_lecturer mysql_fetch_assoc($lecturer);
    $totalRows_lecturer mysql_num_rows($lecturer);

    mysql_select_db($database_connection$connection);
    $query_advisor "SELECT * FROM lecturer WHERE lect_id='$_REQUEST[lect_id]'";
    $advisor mysql_query($query_advisor$connection) or die(mysql_error());
    $row_advisor mysql_fetch_assoc($advisor);
    $totalRows_advisor mysql_num_rows($advisor);

    mysql_select_db($database_connection$connection);
    $query_student "SELECT * FROM student WHERE lect_id='$_REQUEST[lect_id]' AND year='$_REQUEST[year]'";
    $student mysql_query($query_student$connection) or die(mysql_error());
    $row_student mysql_fetch_assoc($student);
    $totalRows_student mysql_num_rows($student);

    mysql_select_db($database_connection$connection);
    $query_editstudent "SELECT * FROM student WHERE student_id='$_REQUEST[student_id]'";
    $editstudent mysql_query($query_editstudent$connection) or die(mysql_error());
    $row_editstudent mysql_fetch_assoc($editstudent);
    $totalRows_editstudent mysql_num_rows($editstudent);

    mysql_select_db($database_connection$connection);
    $query_admin "SELECT * FROM admin WHERE admin_id='$_REQUEST[admin_id]'";
    $admin mysql_query($query_admin$connection) or die(mysql_error());
    $row_admin mysql_fetch_assoc($admin);
    $totalRows_admin mysql_num_rows($admin);

    mysql_select_db($database_connection$connection);
    $query_vstudent "SELECT * FROM student WHERE student_id='$_REQUEST[student_id]'";
    $vstudent mysql_query($query_vstudent$connection) or die(mysql_error());
    $row_vstudent mysql_fetch_assoc($vstudent);
    $totalRows_vstudent mysql_num_rows($vstudent);

    $maxRows_transcript 60;
    $pageNum_transcript 0;
    if (isset(
    $_GET['pageNum_transcript'])) {
    $pageNum_transcript $_GET['pageNum_transcript'];
    }
    $startRow_transcript $pageNum_transcript $maxRows_transcript;

    mysql_select_db($database_connection$connection);
    $query_transcript "SELECT * FROM transcript WHERE student_id='$_REQUEST[student_id]'";
    $query_limit_transcript sprintf("%s LIMIT %d, %d"$query_transcript$startRow_transcript$maxRows_transcript);
    $transcript mysql_query($query_limit_transcript$connection) or die(mysql_error());
    $row_transcript mysql_fetch_assoc($transcript);

    if (isset(
    $_GET['totalRows_transcript'])) {
    $totalRows_transcript $_GET['totalRows_transcript'];
    } else {
    $all_transcript mysql_query($query_transcript);
    $totalRows_transcript mysql_num_rows($all_transcript);
    }
    $totalPages_transcript ceil($totalRows_transcript/$maxRows_transcript)-1;

    $maxRows_course 500;
    $pageNum_course 0;
    if (isset(
    $_GET['pageNum_course'])) {
    $pageNum_course $_GET['pageNum_course'];
    }
    $startRow_course $pageNum_course $maxRows_course;

    mysql_select_db($database_connection$connection);
    $query_course "SELECT * FROM course";
    $query_limit_course sprintf("%s LIMIT %d, %d"$query_course$startRow_course$maxRows_course);
    $course mysql_query($query_limit_course$connection) or die(mysql_error());
    $row_course mysql_fetch_assoc($course);

    if (isset(
    $_GET['totalRows_course'])) {
    $totalRows_course $_GET['totalRows_course'];
    } else {
    $all_course mysql_query($query_course);
    $totalRows_course mysql_num_rows($all_course);
    }
    $totalPages_course ceil($totalRows_course/$maxRows_course)-1;


    <
    input type="hidden" name="MM_update" value="frmyear11" />
    </
    form>
    <!-- 
    Year 1 Semester I -->
    <!-- 
    Year 1 Semester II -->
    <?
    php }else if($_REQUEST['edit']==12){ ?>
    <form action="<?php echo $editFormAction?>" id="frmyear12" name="frmyear12" method="POST">
    <table width="212" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr align="center" bgcolor="#408080">
    <td height="23" colspan="3"><strong style="color: #FFF; font-size: 13px;">Year 1 - Semester II</strong></td>
    </tr>
    <tr bgcolor="#D6F5F5">
    <td width="100" height="22">&nbsp;&nbsp;&nbsp; Credit Hour</td>
    <td width="12" height="22">/td>
    <td width="100" height="22">
    <strong id="sprytextfield19">
    <label>
    <input style="color: #009; font-family: Verdana, Geneva, sans-serif; font-size: 11px;" name="ch12" type="text" id="ch12" value="<?php echo $row_vstudent['ch12']; ?>" size="8" maxlength="2" />
    </label>
    </strong>
    </td>
    </tr>
    <tr bgcolor="#FFFFCC">
    <td width="100" height="22">&nbsp;&nbsp;&nbsp; GPA</td>
    <td width="12" height="22">/td>
    <td width="100" height="22">
    <strong id="sprytextfield20">
    <label>
    <input style="color: #009; font-family: Verdana, Geneva, sans-serif; font-size: 11px;" name="gpa12" type="text" id="gpa12" value="<?php echo $row_vstudent['gpa12']; ?>" size="8" maxlength="5" />
    </label>
    </strong>
    </td>
    </tr>
    <tr bgcolor="#D6F5F5">
    <td width="100" height="22">&nbsp;&nbsp;&nbsp; CGPA</td>
    <td width="12" height="22" align="left">/td>
    <td width="100" height="22">
    <strong id="sprytextfield21">
    <label>
    <input style="color: #009; font-family: Verdana, Geneva, sans-serif; font-size: 11px;" name="cgpa12" type="text" id="cgpa12" value="<?php echo $row_vstudent['cgpa12']; ?>" size="8" maxlength="5" />
    </label>
    </strong>
    </td>
    </tr>
    <tr>
    <td height="3" colspan="3">
    <input name="student_id" type="hidden" id="student_id" value="<?php echo $row_vstudent['student_id']; ?>" />
    <input name="graph" type="hidden" id="graph" value="show" />
    <input name="stu" type="hidden" id="stu" value="student" />
    <input name="lect_id" type="hidden" id="lect_id"
    Last edited by SpacePhoenix; Nov 4, 2011 at 13:40.

  5. #5
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Php Beginner View Post
    I am also having the undefined index error on the line of 311 which I have highlighted it below.
    I don't see any highlighted line. Could you post just line 311 please?

  6. #6
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    yep and you will keep getting them time and again for each query that tries to use a $_REQUEST variable that HAS NOT BEEN SET.

    You have a whole load of queries which will fail
    Code PHP:
    mysql_select_db($database_connection, $connection);
    $query_lecturer = "SELECT * FROM lecturer WHERE dept='$_REQUEST[dept]'";
    $lecturer = mysql_query($query_lecturer, $connection) or die(mysql_error());
    $row_lecturer = mysql_fetch_assoc($lecturer);
    $totalRows_lecturer = mysql_num_rows($lecturer);
     
     
    mysql_select_db($database_connection, $connection);
    $query_advisor = "SELECT * FROM lecturer WHERE lect_id='$_REQUEST[lect_id]'";
    $advisor = mysql_query($query_advisor, $connection) or die(mysql_error());
    $row_advisor = mysql_fetch_assoc($advisor);
    $totalRows_advisor = mysql_num_rows($advisor);
     
     
    mysql_select_db($database_connection, $connection);
    $query_student = "SELECT * FROM student WHERE lect_id='$_REQUEST[lect_id]' AND year='$_REQUEST[year]'";
    $student = mysql_query($query_student, $connection) or die(mysql_error());
    $row_student = mysql_fetch_assoc($student);
    $totalRows_student = mysql_num_rows($student);
     
     
    mysql_select_db($database_connection, $connection);
    $query_editstudent = "SELECT * FROM student WHERE student_id='$_REQUEST[student_id]'";
    $editstudent = mysql_query($query_editstudent, $connection) or die(mysql_error());
    $row_editstudent = mysql_fetch_assoc($editstudent);
    $totalRows_editstudent = mysql_num_rows($editstudent);
     
     
    mysql_select_db($database_connection, $connection);
    $query_admin = "SELECT * FROM admin WHERE admin_id='$_REQUEST[admin_id]'";
    $admin = mysql_query($query_admin, $connection) or die(mysql_error());
    $row_admin = mysql_fetch_assoc($admin);
    $totalRows_admin = mysql_num_rows($admin);
     
     
    mysql_select_db($database_connection, $connection);
    $query_vstudent = "SELECT * FROM student WHERE student_id='$_REQUEST[student_id]'";
    $vstudent = mysql_query($query_vstudent, $connection) or die(mysql_error());
    $row_vstudent = mysql_fetch_assoc($vstudent);
    $totalRows_vstudent = mysql_num_rows($vstudent);

    All these that use $_REQUEST will fail if the value has not been sent from the form.
    You need to check if a variable is there before trying to use it.
    See the previous code I gave you.

    Also you only need to connect to the database once which I assume you are doing in connections.php
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  7. #7
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    Not to mention that you're using constants as indexes - PHP is silently throwing a bunch of warnings at you.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  8. #8
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,014
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Also you should be sanitizing any data that comes from the $_REQUEST array before you let it anywhere near your database (read up about what SQL injection attacks are).
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  9. #9
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Kuching, Sarawak
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks All. I solved my problem. =)

  10. #10
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Kuching, Sarawak
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there, this is another undefined index notice. It says "program" is undefined but I did the same to the "year" and it work fine. Do not know what cause only the "program" to be undefined. See the highlighted line below.

    Here the codes:

    <label>
    <select style="color: #009; font-family: Verdana, Geneva, sans-serif; font-size: 11px;" name="year" id="year">
    <option value="1" <?php if (!(strcmp(1, $_REQUEST['year']))) {echo "selected=\"selected\"";} ?>>1</option>
    <option value="2" <?php if (!(strcmp(2, $_REQUEST['year']))) {echo "selected=\"selected\"";} ?>>2</option>
    <option value="3" <?php if (!(strcmp(3, $_REQUEST['year']))) {echo "selected=\"selected\"";} ?>>3</option>
    <option value="4" <?php if (!(strcmp(4, $_REQUEST['year']))) {echo "selected=\"selected\"";} ?>>4</option>
    <option value="5" <?php if (!(strcmp(5, $_REQUEST['year']))) {echo "selected=\"selected\"";} ?>>5</option>
    <option value="6" <?php if (!(strcmp(5, $_REQUEST['year']))) {echo "selected=\"selected\"";} ?>>6</option>
    </select>
    </label>
    </strong>
    <strong style="color: #F00; font-size: 10px;">*</strong>
    </td>
    <tr bgcolor="#FFFFCC">
    <td width="118" height="22"><strong>&nbsp;&nbsp;&nbsp;Programme</strong></td>
    <td width="12" height="22"><strong>/strong></td>
    <td width="420" height="22">
    <strong id="spryselect14">

    <label>
    <select style="color: #009; font-family: Verdana, Geneva, sans-serif; font-size: 11px;" name="program" id="program">
    <option value="Electronic and Computer Engineering" <?php if (!(strcmp("Electronic and Computer Engineering", $_REQUEST['program']))) {echo "selected=\"selected\"";} ?>>Electronic and Computer Engineering</option>
    <option value="Electronic and Telecommunication Engineering" <?php if (!(strcmp("Electronic and Telecommunication Engineering", $_REQUEST['program']))) {echo "selected=\"selected\"";} ?>>Electronic and Telecommunication Engineering</option>
    <option value="Civil Engineering" <?php if (!(strcmp("Civil Engineering", $_REQUEST['program']))) {echo "selected=\"selected\"";} ?>>Civil Engineering</option>
    <option value="Mechanical Engineering" <?php if (!(strcmp("Mechanical Engineering", $_REQUEST['program']))) {echo "selected=\"selected\"";} ?>>Mechanical Engineering</option>
    <option value="Chemical Engineering" <?php if (!(strcmp("Chemical Engineering", $_REQUEST['program']))) {echo "selected=\"selected\"";} ?>>Chemical Engineering</option>
    </select>
    </label>

  11. #11
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Kuching, Sarawak
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks to everyone who helped and trying to help. My problems solved for the moment.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •