0

messages.php

<!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>Transdmin Light</title>

<!-- CSS -->
<link href="style/css/transdmin.css" rel="stylesheet" type="text/css" media="screen" />
<!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="style/css/ie6.css" /><![endif]-->
<!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="style/css/ie7.css" /><![endif]-->

<!-- JavaScripts-->
<script type="text/javascript" src="style/js/jquery.js"></script>
<script type="text/javascript" src="style/js/jNice.js"></script>
</head>

<body>
    <div id="wrapper">
        <!-- h1 tag stays for the logo, you can use the a tag for linking the index page -->
        <h1><a href="#"><span>Transdmin Light</span></a></h1>
        <img src="images/logo2.png" height="70px" style="margin: -45px 0 0 -180px; position: absolute;"><br><!--<img src="images/admin.png" height="60px" style="margin: -20px 0 0 430px">--><br><br>
        <!-- You can name the links with lowercase, they will be transformed to uppercase by CSS, we prefered to name them with uppercase to have the same effect with disabled stylesheet -->
        <ul id="mainNav">
            <li><a href="#" class="active">DASHBOARD</a></li> <!-- Use the "active" class for the active menu item  -->
            <li><a href="#">ADMIN PAGE</a></li>
            <li class="logout"><a href="#">LOGOUT</a></li>
            <li class="logout"><a href="#"><img src="images/mail.png"></a></li>
            <li class="logout"><a href="#">ADMIN</a></li>           
        </ul>
        <!-- // #end mainNav -->

        <div id="containerHolder">
            <div id="container">
                <div id="sidebar">

                    <?php include("admin_nav.php"); ?>

                    <!-- // .sideNav -->
                </div>    
                <!-- // #sidebar -->

                <div style="margin: -15px 0 0 230px; width: 700px; position: absolute;">
                <!-- h2 stays for breadcrumbs -->
                <h2><a href="#">Dashboard</a> &raquo; <a href="#" class="active">Messages</a></h2>
                </div>

                <!--
                <div id="main">
                    <form action="" class="jNice">
                    <h3>Group Management</h3>
                        <table cellpadding="0" cellspacing="0">
                            <tr>
                                <td>Vivamus rutrum nibh in felis tristique vulputate</td>
                                <td class="action"><a href="#" class="view">View</a><a href="#" class="edit">Edit</a><a href="#" class="delete">Delete</a></td>
                            </tr>                        
                            <tr class="odd">
                                <td>Duis adipiscing lorem iaculis nunc</td>
                                <td class="action"><a href="#" class="view">View</a><a href="#" class="edit">Edit</a><a href="#" class="delete">Delete</a></td>
                            </tr>                        
                            <tr>
                                <td>Donec sit amet nisi ac magna varius tempus</td>
                                <td class="action"><a href="#" class="view">View</a><a href="#" class="edit">Edit</a><a href="#" class="delete">Delete</a></td>
                            </tr>                        
                            <tr class="odd">
                                <td>Duis ultricies laoreet felis</td>
                                <td class="action"><a href="#" class="view">View</a><a href="#" class="edit">Edit</a><a href="#" class="delete">Delete</a></td>
                            </tr>                        
                            <tr>
                                <td>Vivamus rutrum nibh in felis tristique vulputate</td>
                                <td class="action"><a href="#" class="view">View</a><a href="#" class="edit">Edit</a><a href="#" class="delete">Delete</a></td>
                            </tr>                        
                        </table>
                    <h3>Edit Group Info</h3>
                        <fieldset>
                            <p><label>Group Name:</label><input type="text" class="text-long" /></p>
                            <p><label>Information:</label><input type="text" class="text-medium" /><input type="text" class="text-small" /><input type="text" class="text-small" /></p>
                            <p><label>Package:</label>
                            <select>
                                <option>Select one</option>
                                <option>Select two</option>
                                <option>Select tree</option>
                                <option>Select one</option>
                                <option>Select two</option>
                                <option>Select tree</option>
                            </select>
                            </p>
                            <p><label>Other Information:</label><textarea rows="1" cols="1"></textarea></p>
                            <input type="submit" value="Submit Query" />
                        </fieldset>
                    </form>
                </div> -->

                <!-- // #main -->

                <!-- Insert New -->

<br><br><br><br>                
<div id="inputberita">

      <br><br><br>

      <p>&nbsp;</p>

  <p>&nbsp;</p><center>

<?php         

      include('includes/koneksi.php');



        //Hapus berita // undefined index: mode



    if (!empty($_REQUEST['id']) && !empty($_REQUEST['mode']) && $_REQUEST['mode'] == "delete")
        {
        $id = $_REQUEST['id'];
        $result = mysql_query("DELETE FROM static_page WHERE id =".$id) or die(mysql_error());

        $confirmation = !$result ? "Gagal menghapus data." : "Data telah terhapus."; 
        }


?>
<div align="center">
    <div style="width:700px;text-align:left;padding-top:5px;">
        <?php  if (isset($confirmation)) { echo $confirmation; } ?>  
        <form method="get" action="<?php $_SERVER['PHP_SELF'] ?>">

                                    <br/>

                        <button type="button" onClick="parent.location='add_message.php'">Compose</button><br><br>

                <?php
                //LOAD INBOX MESSAGES

                $result = mysql_query("SELECT * FROM messages WHERE to_stu_username='".$_SESSION['username']."' ORDER BY date") or die(mysql_error());
                ?>
                <table id="admintable" border="1" cellpadding="2" cellspacing="0" width="900px">
                    <tr>
                    <b>Inbox</b><br><br>
                        <th>From</th><th style="width:500px;">Messages</th><th>Date</th>
                    </tr>
                    <?php
                    $i=0;
                    while ($data = mysql_fetch_array($result)){
                    $result2=($i%2)?'#DFA09D':'white';


                            echo "<tr bgcolor='$result2'>";                  
                            echo '<td>'.$data['from_stu_username'].'</td>';
                            echo '<td>'.$data['messages'].'</td>';                            
                            echo '<td>'.$data['date'].'</td>';
                            echo '</tr>';

                    $i++;   
                    }
                    ?>
                </table>

                <?php
                //LOAD OUTBOX MESSAGES
                echo "hello :".$_SESSION['username'];

                $result = mysql_query("SELECT * FROM messages WHERE from_stu_username='".$_SESSION['username']."' ORDER BY date") or die(mysql_error());
                ?>
                <table id="admintable" border="1" cellpadding="2" cellspacing="0" width="900px">
                    <tr>
                    <br><br><b>Sent</b><br><br>
                        <th>To</th><th style="width:500px;">Messages</th><th>Date</th>
                    </tr>
                    <?php
                    $i=0;
                    while ($data = mysql_fetch_array($result)){
                    $result2=($i%2)?'#DFA09D':'white';


                            echo "<tr bgcolor='$result2'>";                  
                            echo '<td>'.$data['to_stu_username'].'</td>';
                            echo '<td>'.$data['messages'].'</td>';                            
                            echo '<td>'.$data['date'].'</td>';
                            echo '</tr>';

                    $i++;   
                    }
                    ?>
                </table>

        </form>
    </div>
</div>
  </center>
</div> 

                <!-- End Insert -->  

                <div class="clear"></div>
            </div>
            <!-- // #container -->
        </div>   
        <!-- // #containerHolder -->

        <p id="footer">Feel free to use and customize it. <a href="http://www.perspectived.com">Credit is appreciated.</a></p>
    </div>
    <!-- // #wrapper -->
</body>
</html>

Notice: Undefined variable: _SESSION in C:\xampp\htdocs\SquprimeRevise2\administrator\admin\messages.php on line 138
Inbox

From Messages Date

Notice: Undefined variable: _SESSION in C:\xampp\htdocs\SquprimeRevise2\administrator\admin\messages.php on line 164
hello :
Notice: Undefined variable: _SESSION in C:\xampp\htdocs\SquprimeRevise2\administrator\admin\messages.php on line 166

Sent

To Messages Date

loginproses.php

<?php

echo $_POST['username'];;

include('includes/koneksi.php');

$error = "";

if (@$_POST['submit']) { 

/* the files */

// username and password sent from form
$username=$_POST['username'];
$password=$_POST['password'];

// To protect MySQL injection (more detail about MySQL injection)

$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

$encrypted_password = md5($password);

$sql = "SELECT * FROM student WHERE stu_username='$username' and stu_password='$encrypted_password' and access_level_id='3'" or die(mysql_query);
$result=mysql_query($sql);

$sql2 = "SELECT * FROM teacher WHERE teach_username='$username' and teach_password='$encrypted_password'" or die(mysql_query);
$result2=mysql_query($sql2);

$sql3 = "SELECT * FROM user WHERE username='$username' and password='$encrypted_password'" or die(mysql_query);
$result3=mysql_query($sql3);

$sql4 = "SELECT * FROM student WHERE stu_username='$username' and stu_password='$encrypted_password' and access_level_id='4'" or die(mysql_query);
$result4=mysql_query($sql4);


// Mysql_num_row is counting table row
$stu_count=mysql_num_rows($result);
$teach_count=mysql_num_rows($result2);
$admin_count=mysql_num_rows($result3);
$stuM_count=mysql_num_rows($result4);

// If result matched $username and $password, table row must be 1 row

if ($stu_count>=1){

// Register $myusername, $mypassword and redirect to file "login_success.php"

$_SESSION['username'] = $username;
$_SESSION['password'] = $password;

header("location:administrator/student/schedule.php");
}
elseif ($stuM_count>=1){

$_SESSION['username'] = $username;
$_SESSION['password'] = $password;

header("location:administrator/studentMaster/groupmgt.php");

}
elseif ($teach_count>=1){

$_SESSION['username'] = $username;
$_SESSION['password'] = $password;

header("location:administrator/teacher/schedule.php");

}
elseif ($admin_count==1){

$_SESSION['username'] = $username;
$_SESSION['password'] = $password;

header("location:administrator/admin/groupmgt.php");

}
else {

?>
<!-- alert add -->

<center>
<div id="user_message3"></div>
</center>

<!-- end -->
<?php

$error = "Please try again.";
}
}
?>

I already crete the $_SESSION['username'] = $username; after login then it takes me to messages.php. The error appears after I migrate my backend to the new backend.

How to fix the undefined $_SESSION?

3
Contributors
3
Replies
17
Views
3 Years
Discussion Span
Last Post by Borzoi
0

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\SquprimeRevise2\administrator\admin\messages.php:106) in C:\xampp\htdocs\SquprimeRevise2\administrator\admin\messages.php on line 108

line 108: session_start();

0

As mattster said, you need to add session_start() at the top of the file. You can't add it after anything else. It needs to be before even the doctype declaration:

<?php session_start(); ?>
<!DOCTYPE ...>
[Rest of content]
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.