http://localhost/squprime/administrator/admin/%3Cbr%20/%3E%3Cb%3ENotice%3C/b%3E:%20%20Undefined%20variable:%20student_id%20in%20%3Cb%3EC:%5Cxampp%5Chtdocs%5Csquprime%5Cadministrator%5Cadmin%5Cadd_student_progtab.php%3C/b%3E%20on%20line%20%3Cb%3E164%3C/b%3E%3Cbr%20/%3E/squprime/administrator/admin/add_student_progtab.php?student_id=

Undefined variable student_id, I wonder why? That url appears after I press save.

add_student_progtab.php

<?php

// Check if session is not registered, redirect back to main page.
// Put this code in first line of web page.

session_start();


if(!isset($_SESSION['username']))
    {
    header("location:index.php");
    exit;
    }


?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Squprime Admin Page</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="keywords" content="rustoleum, coating" />
<meta name="description" content="Rustoleum Indonesia provides coating solution for industrial requirement and individual needs." />

<style type="text/css">
#slideshow { left: 35px; float: left; margin: 10px; z-index: 0;}
#nav { width: 270px; margin: 170px 0 0 225px; float: left; position: absolute; z-index: 1;}
#nav li { float: left; margin: 0 0 0 4px; list-style: none; background: url(images/pager3-2.jpg) no-repeat top;}
#nav a { width: 40px; padding: 3px; display: block; border: 1px solid #ccc;}
#nav li.activeSlide a { /* background: #88f */ background: url(images/pager3.jpg) no-repeat top;}
#nav a:focus { outline: none;}
#nav img { border: none; display: block;}
pre { clear: left }
</style>
<script src="../../js/jquery.min.js" type="text/javascript"></script>
<script src="../../js/chili-1.7.pack.js"></script>
<script src="../../js/jquery.cycle.all.js" type="text/javascript"></script>
<script src="../../js/jquery.easing.1.3.js" type="text/javascript" ></script>
<link href= "../../css/admin.css" rel="stylesheet" type="text/css" media="screen">
<link href= "../../css/navstyleadmin.css" rel="stylesheet" type="text/css" media="screen">

<script type="text/javascript">
$('#slideshow').cycle({ 
    fx:     'fade', 
    speed:   900, 
    timeout: 10000, 
    pager:  '#nav', 
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '#nav li:eq(' + idx + ') a'; 
    } 
});
</script>

<script src="ckeditor/ckeditor.js"></script>
</head>

<div id="main-wrap1">
<body>

<?php include('../header2.php'); ?>

<?php   include("../adminnavcssjs.php");  ?>
<?php   include("../adminnav2.php");  ?>

<!-- <hr style="height:400px;width:1px;border-color:#eeeeee;margin: -50px 0 0 220px;" /> --> 

<img src="../images/line.png" style="repeat-x; width: 10px; height:800px; margin: -60px 0 0 10px;">


<div id="menu" style="margin-top: -700px;">
      <?php// if (empty($_GET['profile_id'])){?>
      <center>        
        <div id="title"><h2>Add Student Progress Table</h2></div>
      </center>
      <p> </p>
      <?php//}else{?> <!--
      <center>        
        <div id="title"><h2>Edit Student Profile</h2></div>
      </center>
      <p> </p>
     <?php// } ?> -->

  <p> </p><center>
      <p>

<?php

    include('../../includes/koneksi.php');

    $study_progtab_id = isset($_POST['study_progtab_id']) ? $_POST['study_progtab_id'] : '';  
    $lesson = isset($_POST['lesson']) ? $_POST['lesson'] : ''; 
    $date = isset($_POST['date']) ? $_POST['date'] : '';  
    $exercise = isset($_POST['exercise']) ? $_POST['exercise'] : '';  
    $weakness = isset($_POST['weakness']) ? $_POST['weakness'] : '';
    $progress = isset($_POST['progress']) ? $_POST['progress'] : '';    
    $teacher_advice = isset($_POST['teacher_advice']) ? $_POST['teacher_advice'] : ''; 
    $homework = isset($_POST['homework']) ? $_POST['homework'] : '';
    $listening = isset($_POST['listening']) ? $_POST['listening'] : ''; 
    $grammar = isset($_POST['grammmar']) ? $_POST['grammar'] : '';
    $conversation = isset($_POST['conversation']) ? $_POST['conversation'] : '';
    $reading = isset($_POST['reading']) ? $_POST['reading'] : '';
    $confirmation = isset($_POST['confirmation']) ? $_POST['confirmation'] : '';
    $confirmation2 = isset($_POST['confirmation2']) ? $_POST['confirmation2'] : '';


    //Simpan berita 
    if (isset($_POST['ok'])){

        if (empty($_GET['study_progtab_id']))
            {

            //$username = substr($stu_fname, 0, 1).$stu_lname;
            //$username = strtolower($username);


            $sqlstr = "INSERT INTO `study_progtab`(lesson, date, exercise, weakness, progress, teacher_advice, homework, listening, grammar, conversation, reading) VALUES('".$lesson."','".$date."', '".$exercise."', '".$weakness."','".$progress."', '".$teacher_advice."', '".$homework."','".$listening."','".$grammar."','".$conversation."','".$reading."')";

            }
        else
        {
            $sqlstr = "UPDATE `study_progtab` SET study_progtab_id='".$study_progtab_id."', lesson='".$lesson."', date='".$date."', exercise='".$exercise."', weakness='".$weakness."', progress='".$progress."', teacher_advice='".$teacher_advice."', homework='".$homework."', listening='".$listening."', grammar='".$grammar."', conversation='".$conversation."', reading='".$reading."' WHERE study_progtab_id=".$_GET['study_progtab_id'];
            //include('studentinfopic_upload.php'); 
        }

        $result = mysql_query($sqlstr) or die(mysql_error());
        //$result2 = mysql_query($sqlstr2) or die(mysql_error());

        //Jika mode edit, maka tidak akan dikirimkan konfirmasi kepada subscriber
        //if (empty($_REQUEST['id']))   kirimEmail($idKategori, $judul, $news);
        $confirmation = ($result) ? "Data has been saved." : "Fail to save data.";
        //$confirmation2 = ($result2) ? "Study Report has been saved." : "Fail to save data.";
    }

        //Load Student Profile
    if (!empty($_GET['student_id'])){
        $result = mysql_query("SELECT * FROM student WHERE student_id =".$_GET['student_id']) or die(mysql_error());
        $data = mysql_fetch_array($result);
        $student_id = $data['student_id'];
        $lesson = $data['lesson'];
        $date = $data['date'];
        $exercise = $data['exercise'];
        $weakness = $data['weakness'];
        $progress = $data['progress'];
        $teacher_advice = $data['teacher_advice'];
        $homework = $data['homework'];
        $listening = $data['listening'];
        $grammar = $data['grammar'];
        $conversation = $data['conversation'];
        $reading = $data['reading'];

    }
    else {
    //echo "unable to select data".'<br>';
    //echo "student_id is empty";
    }
    ?>
    <div align="center">
        <div style="width:800px;text-align:left;">
        <?php echo $confirmation;?>
        <?php //echo $confirmation2;?>
        <form method="post" action="<?php echo $_SERVER['PHP_SELF'] .'?student_id='.$student_id;?>">
            <!-- <input type="hidden" name="id" value="<?php// echo $id; ?>"/>-->
            <table>

                <tr>
                    <td>Lesson</td>               
                    <td>
                    <?php

                    $rs = mysql_query("SELECT * FROM class") or die(mysql_error());                 
                    echo "<select name='lesson'>";
                    while($data = mysql_fetch_array($rs)){
                        echo "<option value='".$data['class_name']."'>".$data['class_name']."</option>";
                        }
                    echo "</select>";

                    ?>
                    </td>
                </tr>
                <tr>
                    <td>Date Time</td>                
                    <td><input type="text" id="datedate" name="datetime" value="<?php echo $datetime; ?>" rows="4" cols="50"></td>
                </tr>
                <tr>
                    <td>Exercise</td>             
                    <td><?php

                    $rs = mysql_query("SELECT * FROM exercise") or die(mysql_error());                  
                    echo "<select name='exercise'>";
                    while($data = mysql_fetch_array($rs)){
                        echo "<option value='".$data['class_name']."'>".$data['class_name']."</option>";
                        }
                    echo "</select>";

                    ?></td>
                </tr>
                <tr>
                    <td>Weakness</td>             
                    <td><input type="text" size="50px" name="weakness" value="<?php echo $weakness; ?>"></td>
                </tr>
                <tr>
                    <td>Progress</td>             
                    <td><input type="text" size="50px" name="progress" value="<?php echo $progress; ?>"></td>
                </tr>
                <tr>
                    <td>Teacher Advice</td>
                    <td><input type="text" size="50px" name="teacher_advice" value="<?php echo $teacher_advice; ?>"/></td>
                </tr>
                <tr>
                    <td>Homework</td>
                    <td><input type="text" size="5px" name="homework" value="<?php echo $homework; ?>"/></td>
                </tr>
                <tr>
                    <td>Listening</td>
                    <td><input type="text" size="5px" name="listening" value="<?php echo $listening; ?>"/></td>
                </tr>
                <tr>
                    <td>Grammar</td>
                    <td><input type="text" size="5px" name="Grammar" value="<?php echo $grammar; ?>"/></td>
                </tr>
                <tr>
                    <td>Conversation</td>
                    <td><input type="text" size="5px" name="conversation" value="<?php echo $conversation; ?>"/></td>
                </tr>
                <tr>
                    <td>Reading</td>
                    <td><input type="text" size="5px" name="reading" value="<?php echo $reading; ?>"/></td>
                </tr>
                <tr>             
                    <td></td>
                    <td><br><input type="submit" name="ok" value="Save" class="abutton"/></td>              

                </tr>
            </table>
        </form>
        </div>
    </div>
</div>    

<script src="jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.maskedinput.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
  $.mask.definitions['~'] = "[+-]";
    $("#datedate").mask("9999-99-99 99:99:99",{completed:function(){alert("completed!");}});
    $("input").blur(function() {
    $("#info").html("Unmasked value: " + $(this).mask());
    }).dblclick(function() {
    $(this).unmask();
  });
});
</script>


<br><br><br><br><br><br>   
<p> </p>

<?php include('../adminfooter.php'); ?>
</body>
</html>

?student_id=

That's why it's undefined, it doesn't have a value.

Line 164 uses $student_id but $student_id may not have been declared. This occurs when line 138 condition is false.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.