Jump to content

Cannot modify header information


aquilina

Recommended Posts

i have problem when adding a subject it got two subject that need to be selected by teacher , management sub and DBMS sub..  said Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\PhpProject3\navhead_user.php:57) in C:\xampp\htdocs\PhpProject3\teacher_add_subject.php on line 104.. when i select one of them it appear that error.. but when i select DBMS it inserted the subject but with error.. let say 1st i selecting management as the subject, it occur error but after refresh the page it appear in the list of the teacher subject then i add another subject DBMS subject and it occur error but the management subject is dissappear from the teach subject list.. but i try to add the management subject again it said it existed but not listed.. but in my database it inside there already only the data not appear..

 

navhead_user.php

<div class="row-fluid">
    <div class="span12">


        <div class="navbar navbar-fixed-top navbar-inverse">
            <div class="navbar-inner">
                <div class="container">

                    <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
                    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </a>

                    <!-- Be sure to leave the brand out there if you want it shown -->


                    <!-- Everything you want hidden at 940px or less, place within here -->



                    <div class="nav-collapse collapse">
                        <!-- .nav, .navbar-search, .navbar-form, etc -->
                       <i class="icon-facebook-sign icon-large" id="color_white"></i>
                        <i class="icon-twitter icon-large" id="color_white"></i>
                        <i class="icon-google-plus icon-large" id="color_white"></i>
                        <i class="icon-github-alt icon-large" id="color_white"></i>
                        <i class="icon-linkedin-sign icon-large" id="color_white"></i>
                        <div class="pull-right">
                            <form class="navbar-search pull-left">
                                
                                <i class="icon-search icon-large" id="color_white"></i>
                                <input type="text" class="search-query" placeholder="Search">
                            </form>
                        </div>

                        <!-- end collapse -->
                    </div>

                </div>
            </div>
        </div>
        <div class="hero-unit-header">
            <div class="container">

                <div class="row-fluid">
                    <div class="span12">
                        <div class="row-fluid">
                            <div class="span6">
                             <img src="admin/images/head.png">

                            </div>
                            <div class="span6">
                                <div class="pull-right">
                                    <!--- login button -->							
                                  <?php 
                                    $student_query=mysql_query("select * from teacher where teacher_id='$session_id'")or die(mysql_error());
                                    $teacher_row=  mysql_fetch_array($student_query);
                                    ?>
                                    
                                     <img  src="admin/<?php echo $teacher_row['location']; ?>"  class="img img-rounded" id="picture">
                                         
                                    <div class="btn-group">
                                       
                                        <button class="btn btn-success"><i class="icon-user icon-large"></i>  <?php echo $user_row['firstname'] . " " . $user_row['lastname']; ?></button>
                                        <button class="btn dropdown-toggle" data-toggle="dropdown">
                                            <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu">
                                            <li><a href="#logout" role="button"  data-toggle="modal"><i class="icon-signout icon-large"></i> Logout</a></li>
                                        </ul>

                                    </div>

                                    <?php include('logout_modal.php') ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>


        </div>

 teacher_add_subject.php

<?php include ('session.php'); ?>
<?php
include('header.php');
$user_query = mysql_query("select * from teacher where teacher_id='$session_id'") or die(mysql_error());
$user_row = mysql_fetch_array($user_query);
?>
<body>

    <?php include('navhead_user.php'); ?>

    <div class="container">
        <div class="row-fluid">
            <div class="span3">
                <div class="hero-unit-3">
                    <div class="alert-index alert-success">
                        <i class="icon-calendar icon-large"></i>
                        <?php
                        $Today = date('y:m:d');
                        $new = date('l, F d, Y', strtotime($Today));
                        echo $new;
                        ?>
                    </div>
                </div>
                <div class="hero-unit-1">
                    <ul class="nav  nav-pills nav-stacked">
                        <li class="nav-header">Links</li>
                        <li>
                            <a href="teacher_home.php"><i class="icon-home icon-large"></i> Home
                                <div class="pull-right">
                                    <i class="icon-double-angle-right icon-large"></i>
                                </div>  
                            </a>

                        </li>
                        <li>
                            <a href="teacher_class.php"><i class="icon-group icon-large"></i> Class
                                <div class="pull-right">
                                    <i class="icon-double-angle-right icon-large"></i>
                                </div>  
                            </a></li>
                        <li  class="active"><a href="teacher_subject.php"><i class="icon-file-alt icon-large"></i> Subjects
                                <div class="pull-right">
                                    <i class="icon-double-angle-right icon-large"></i>
                                </div>  
                            </a></li>
                        <li><a href="students.php"><i class="icon-group icon-large"></i> Students
                                <div class="pull-right">
                                    <i class="icon-double-angle-right icon-large"></i>
                                </div>  
                            </a></li>


                    </ul>
                </div>

            </div>
            <div class="span9">
                <a href="teacher_subject.php" class="btn btn-success"><i class="icon-arrow-left icon-large"></i> Back</a>
                <br>
                <br>

                <div class="alert alert-info">
                    <button type="button" class="close" data-dismiss="alert">×</button>
                    <strong><i class="icon-user icon-large"></i> Add Subject</strong>
                </div>
                <div class="hero-unit-2">
                    <form class="form-horizontal" method="POST">
                        <div class="control-group">
                            <label class="control-label" for="inputEmail">Subject</label>
                            <div class="controls">

                                <select name="subject" class="span6">
                                    <option></option>
                                    <?php
                                    $query = mysql_query("select * from subject") or die(mysql_error());
                                    while ($row = mysql_fetch_array($query)) {
                                        ?>
                                        <option value="<?php echo $row['subject_id']; ?>"><?php echo $row['subject_title']; ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>

                        <div class="control-group">
                            <div class="controls">
                                <button type="submit" name="save_subject" class="btn btn-success"><i class="icon-plus-sign icon-large"></i> Add Subject</button>
                            </div>
                            <br>
                            <?php
                            if (isset($_POST['save_subject'])) {
                                $subject = $_POST['subject'];

                                $result = mysql_query("select * from teacher_suject where teacher_id='$session_id' and subject_id='$subject'") or die(mysql_error());
                                $count = mysql_num_rows($result);

                                if ($count > 0) {
                                    ?>
                                    <div class="alert alert-danger">Subject <strong>Already Exist</strong></div>
                                    <?php
                                } else {


                                    mysql_query("insert into teacher_suject (subject_id,teacher_id) values('$subject','$session_id')") or die(mysql_error());
                                    header('location:teacher_subject.php');
                                }
                            }
                            ?>

                        </div>
                    </form>



                    <!-- end slider -->
                </div>
            </div>

        </div>
        <?php include('footer.php'); ?>
    </div>
</div>
</div>






</body>
</html>




teacher_subject.php

<?php include ('session.php'); ?>
<?php
include('header.php');
$user_query = mysql_query("select * from teacher where teacher_id='$session_id'") or die(mysql_error());
$user_row = mysql_fetch_array($user_query);
?>
<body>

    <?php include('navhead_user.php'); ?>

    <div class="container">
        <div class="row-fluid">
            <div class="span3">
                <div class="hero-unit-3">
                    <div class="alert-index alert-success">
                        <i class="icon-calendar icon-large"></i>
                        <?php
                        $Today = date('y:m:d');
                        $new = date('l, F d, Y', strtotime($Today));
                        echo $new;
                        ?>
                    </div>
                </div>
                <div class="hero-unit-1">
                    <ul class="nav  nav-pills nav-stacked">
                        <li class="nav-header">Links</li>
                        <li>
                            <a href="teacher_home.php"><i class="icon-home icon-large"></i> Home
                                <div class="pull-right">
                                    <i class="icon-double-angle-right icon-large"></i>
                                </div>  
                            </a>

                        </li>
                        <li>
                            <a href="teacher_class.php"><i class="icon-group icon-large"></i> Class
                                <div class="pull-right">
                                    <i class="icon-double-angle-right icon-large"></i>
                                </div>  
                            </a></li>
                        <li   class="active"><a href="teacher_subject.php"><i class="icon-file-alt icon-large"></i> Subjects
                                <div class="pull-right">
                                    <i class="icon-double-angle-right icon-large"></i>
                                </div>  
                            </a></li>
                        <li><a href="students.php"><i class="icon-group icon-large"></i> Students
                                <div class="pull-right">
                                    <i class="icon-double-angle-right icon-large"></i>
                                </div>  
                            </a></li>


                    </ul>
                </div>

            </div>
            <div class="span9">



                <a href="teacher_add_subject.php" class="btn btn-success"><i class="icon-plus-sign icon-large"></i> Add Subject</a>
                <br>
                <br>
                <div class="hero-unit-3">
                    <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
                        <div class="alert alert-info">
                            <button type="button" class="close" data-dismiss="alert">×</button>
                            <strong><i class="icon-user icon-large"></i> Subject Table</strong>
                        </div>
                        <thead>
                            <tr>

                                <th>Course Code</th>
                                <th>Course Description</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $teacher_subject_query = mysql_query("select * from teacher_suject where teacher_id='$session_id'") or die(mysql_error());
                            $teacher_row = mysql_fetch_array($teacher_subject_query);
                            $subject_id = $teacher_row['subject_id'];

                            $query = mysql_query("select * from subject where subject_id = '$subject_id'") or die(mysql_error());
                            while ($row = mysql_fetch_array($query)) {
                                $id = $row['subject_id'];
                                ?>
                                   <!-- script -->
                            <script type="text/javascript">
                                $(document).ready(function(){
                                
                                    $('#d<?php echo $subject_id; ?>').tooltip('show')
                                    $('#d<?php echo $subject_id; ?>').tooltip('hide')
                                });
                            </script>
                            <!-- end script -->
                            <!-- script -->
                            <script type="text/javascript">
                                $(document).ready(function(){
                                
                                    $('#e<?php echo $subject_id; ?>').tooltip('show')
                                    $('#e<?php echo $subject_id; ?>').tooltip('hide')
                                });
                            </script>
                            <!-- end script -->

                                <tr class="odd gradeX">

                                    <td><?php echo $row['subject_code']; ?></td> 
                                    <td><?php echo $row['subject_title']; ?></td> 

                                    <td width="50">
                                        <a rel="tooltip"  title="Delete Subject" id="d<?php echo $subject_id; ?>" href="#id<?php echo $id; ?>" role="button"  data-toggle="modal" class="btn btn-danger"><i class="icon-trash icon-large"></i> </a>
                                       
                                    </td>
                                    <!-- user delete modal -->
                            <div id="id<?php echo $id; ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-header">
                                </div>
                                <div class="modal-body">
                                    <div class="alert alert-danger">Are you Sure you Want to <strong>Delete</strong>  this Subject?</div>
                                </div>
                                <div class="modal-footer">
                                    <button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove icon-large"></i> Close</button>
                                    <a href="delete_teacher_course.php<?php echo '?id=' . $course_id; ?>" class="btn btn-danger"><i class="icon-trash icon-large"></i> Delete</a>
                                </div>
                            </div>
                            <!-- end delete modal -->

                            </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                    <!-- end slider -->
                </div>
            </div>

        </div>
        <?php include('footer.php'); ?>
    </div>
</div>
</div>






</body>
</html>



Edited by aquilina
Link to comment
Share on other sites

 

output buffering should only be used when you want to buffer output, not to try to prevent errors when your code runs. the way to fix an error is to correct the underlying problem that is causing it.

so the header('location:teacher_subject.php'); << should not in that teacher_add_subject.php.. but in the table it should show the two subject.. it only appear one subject but not both.. since in database i have 2 subject registered...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.