0

Im having a nasty Bug here, here is the error.

Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\teacher_modal.php on line 57

Warning: session_regenerate_id(): Cannot regenerate session id - headers already sent in C:\xampp\htdocs\teacher_modal.php on line 58

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\navhead.php:66) in C:\xampp\htdocs\teacher_modal.php on line 60

These error came out after I loggin to my site using localhosting then im just stock on loggin page because it cannot continue because of that error.

but in my Paid Webhosting i have no problem with my site it run smoothly indeed.

if anyone can help me i will give you a reward tnx

Here is the Page code php:

<!-- modal -->

<div id="teacher" 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-info">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <strong>Login Teacher!</strong>&nbsp;Please Enter the Details Below.
        </div>
        <form class="form-horizontal" method="post">
            <div class="control-group">
                <label class="control-label" for="inputEmail">Username</label>
                <div class="controls">
                    <input type="text" name="username" id="inputEmail" placeholder="Username">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputPassword">Password</label>
                <div class="controls">
                    <input type="password" name="password" id="inputPassword" placeholder="Password">
                </div>
            </div>


            <div class="control-group">
                <div class="controls">
                    <button type="submit" name="login_teacher" class="btn btn-info"><i class="icon-signin icon-large"></i>&nbsp;Sign in</button>
                </div>


            </div>

            <?php
            if (isset($_POST['login_teacher'])) {

                function clean($str) {
                    $str = @trim($str);
                    if (get_magic_quotes_gpc()) {
                        $str = stripslashes($str);
                    }
                    return mysql_real_escape_string($str);
                }

                $username = clean($_POST['username']);
                $password = clean($_POST['password']);

                $query = mysql_query("select * from teacher where username='$username' and password='$password'") or die(mysql_error());
                $count = mysql_num_rows($query);
                $row = mysql_fetch_array($query);


                if ($count > 0) {
                    session_start();
                    session_regenerate_id();
                    $_SESSION['id'] = $row['teacher_id'];
                    header('location:teacher_home.php');
                    session_write_close();
                    exit();
                } else {
                    session_write_close();
                    ?>
                    <div class="pull-right">   
                        <button type="button" class="close" data-dismiss="alert">&times;</button>
                        <div class="alert alert-danger"><i class="icon-remove-sign"></i>&nbsp;Access Denied</div>
                    </div>
                    <?php
                    exit();
                }
            }
            ?>
        </form>


        <!-- teacher -->




    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove-sign icon-large"></i>&nbsp;Close</button>

    </div>
</div

<!-- end modal -->

PS: i also tried moving the session_start(); before the cycle still nothing. and i also tried the encoding without BOM still nothing :) if someone can help me it will be a big help tnx.

carlo
  • 1
  • 1

2 Answers2

0

session_start() must be the first line of code, for example, in index.php before any other output

Ehab Eldeeb
  • 722
  • 4
  • 12
0

if you want to get the whole website file just recomment and add me in Facebook : https://www.facebook.com/pronten22

carlo
  • 1
  • 1