doushansu9012 2017-03-01 09:39
浏览 32

体验未定义的索引和会话已经开始

I have tried some answers given here on stackoverflow relating to undefined index and session already started, but still dont seem to get whats wrong. the below code is the whole code in the index.php file

Please someone should guide me or assist me on what im doing wrongly or didnt get right.

    <?php 

// check for minimum PHP version
if (version_compare(PHP_VERSION, '5.3.7', '<')) {
    exit('Sorry, this script does not run on a PHP version smaller than 5.3.7 !');
} else if (version_compare(PHP_VERSION, '5.5.0', '<')) {
    // if you are using PHP 5.3 or PHP 5.4 you have to include the password_api_compatibility_library.php
    // (this library adds the PHP 5.5 password hashing functions to older versions of PHP)
    require_once('./php-login-advanced-master/libraries/password_compatibility_library.php');
}
// include the config
require_once('./php-login-advanced-master/config/config.php');

// include the to-be-used language, english by default. feel free to translate your project and include something else
require_once('./php-login-advanced-master/translations/en.php');

// include the PHPMailer library
require_once('./php-login-advanced-master/libraries/PHPMailer.php');

// load the login class
require_once('./php-login-advanced-master/classes/Login.php');
// load match class
require_once('./php_scrips/matching.php');
// load the registration class
require_once('./php-login-advanced-master/classes/Registration.php');
// create the registration object. when this object is created, it will do all registration stuff automatically
// so this single line handles the entire registration process.
$registration = new Registration();

// create a login object. when this object is created, it will do all login/logout stuff automatically
// so this single line handles the entire login process.
$login = new Login();
//create a match object
$match = new match();

?>
 <body>
            <ul class="nav navbar-right top-nav">
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> <?php echo $_SESSION[user_name] ?> <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                    <?php 
if(isset($_SESSION['user_email'])){
    echo '
                        <li><a href="./"><i class="fa fa-dashboard"></i> My Dashboard</a></li>
                        <li><a href="./my_profile"><i class="fa fa-user"></i> My Profile</a></li>';          
              if($_SESSION['user_level']=='ADMINISTRATOR'){
                  echo '<li><a href="./rematch">Rematch Member</a></li>
                        <li><a href="./set_recovery_question">Set User Recovery Question</a></li>
                        <li><a href="./rematch_admins">Rematch Admins</a></li>';
              }
              echo '
                        <li><a href="./pending_payments"><i class="fa fa-warning"></i> Pending Payments</a></li>
                        <li><a href="./paid_members"><i class="fa fa-money"></i> Paid Members</a></li>
                        <li class="divider"></li>
                        <li>
                            <a href="./?logout=Log out"><i class="fa fa-fw fa-power-off"></i> Log Out</a>
                        </li>';
}?>
                    </ul>
                </li>
            </ul>
 <?php            
if(isset($_SESSION['user_email'])){
    echo '<!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
            <div class="collapse navbar-collapse navbar-ex1-collapse">
                <ul class="nav navbar-nav side-nav">
                    <li class="active"><a href="./"><i class="fa fa-dashboard"></i> My Dashboard</a></li>
                    <li><a href="./my_profile"><i class="fa fa-user"></i> My Profile</a></li>';

          if($_SESSION['user_level']=='ADMINISTRATOR'){
              echo '<li><a href="./rematch">Rematch Member</a></li>
                    <li><a href="./set_recovery_question">Set User Recovery Question</a></li>
                    <li><a href="./rematch_admins">Rematch Admins</a></li>';
          }
          echo '
                    <li><a href="./pending_payments"><i class="fa fa-warning"></i> Pending Payments</a></li>
                    <li><a href="./paid_members"><i class="fa fa-money"></i> Paid Members</a></li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </nav>
        <div id="page-wrapper">

            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Dashboard <small>Statistics Overview</small>
                        </h1>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Dashboard
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <div class="row">
                    <div class="col-lg-12">
                        <div class="alert alert-info alert-dismissable">
                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                            <i class="fa fa-info-circle"></i>  <strong>Please note that your account will be automatically deleted once you complete your cycle.<br/>To continue with the TapFortune system for the 2nd or as many times as posible, you have to register for every cycle.
                        </div>
                    </div>
                </div>
                <!-- /.row -->';

            $match->to_pay($_SESSION['user_to_pay'],$_SESSION['user_status']);
            $match->to_get($_SESSION['user_email'],$_SESSION['user_status']);
          echo '<!--
                <div class="row">
                    <div class="col-lg-4">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title"><i class="fa fa-clock-o fa-fw"></i> Last 10 Sign Ups</h3>
                            </div>
                            <div class="panel-body">
                                <div class="list-group">
                                    <a href="#" class="list-group-item">
                                        <span class="badge">just now</span>
                                        <i class="fa fa-fw fa-user"></i> Egere Samuel
                                    </a>
                                    <a href="#" class="list-group-item">
                                        <span class="badge">just now</span>
                                        <i class="fa fa-fw fa-user"></i> Egere Samuel
                                    </a>
                                    <a href="#" class="list-group-item">
                                        <span class="badge">just now</span>
                                        <i class="fa fa-fw fa-user"></i> Egere Samuel
                                    </a>
                                    <a href="#" class="list-group-item">
                                        <span class="badge">just now</span>
                                        <i class="fa fa-fw fa-user"></i> Egere Samuel
                                    </a>
                                </div>
                                <div class="text-right">
                                    <a href="#"> See More <i class="fa fa-arrow-circle-right"></i></a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>-->
                <!-- /.row -->

            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->';
}
if(!isset($_SESSION['user_email']) && !isset($_GET['reg']) && !isset($_GET['password_rest']) && !isset($_SESSION['user_reset'])){
    echo '<!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
            <div class="collapse navbar-collapse navbar-ex1-collapse">
                <ul class="nav navbar-nav side-nav">
                    <li class="active"><a href="./">Login</a></li>
                    <li><a href="./?reg">Sign Up</a></li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
    </nav>
        <div id="page-wrapper">

            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Login
                        </h1>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Login
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <div class="row">   
                    <div class="col-xs-1 col-sm-3 col-md-3 col-lg-4"></div>
                    <div class="col-xs-10 col-sm-6 col-md-6 col-lg-4" style="margin-bottom:200px">'
                    .$registration->messages['recovery_reset_successful'].'
                      <form method="post" enctype="application/x-www-form-urlencoded">
                        <div class="form-group">
                          <label for="username">Email</label>
                          <input type="text" name="user_name" class="form-control" placeholder="Enter Email">
                        </div>'
                        .$login->errors['invalid_email'].'
                        <div class="form-group">
                          <label for="username">Password</label>
                          <input type="password" name="user_password" class="form-control" placeholder="Enter Password">
                        </div>'
                        .$login->errors['Login_failed'].$login->errors['wrong_password'].'
                        <div class="checkbox">
                          <label>
                            <input type="checkbox" name="user_rememberme" value="1">
                            Remember me </label>
                        </div>
                        <div>
                          <input type="submit" name="login" value="Sign In" class="btn btn-success btn-block" style="font-size:18px; font-weight:900" />
                        </div>
                        <div>
                          <a href="./?password_rest">Forgotten password</a>
                        </div>
                      </form>
                    </div>
                    <div class="col-xs-1 col-sm-3 col-md-3 col-lg-4"></div>
                </div>
                <!-- /.row -->

            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->';
}
if(!isset($_SESSION['user_email']) && isset($_GET['password_rest'])){
    echo '<!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
            <div class="collapse navbar-collapse navbar-ex1-collapse">
                <ul class="nav navbar-nav side-nav">
                    <li class="active"><a href="./">Login</a></li>
                    <li><a href="./?reg">Sign Up</a></li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
    </nav>
        <div id="page-wrapper">

            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Password Reset
                        </h1>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Password Reset
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <div class="row">   
                    <div class="col-xs-1 col-sm-3 col-md-3 col-lg-4"></div>
                    <div class="col-xs-10 col-sm-6 col-md-6 col-lg-4" style="margin-bottom:200px">
                      <form method="post" enctype="application/x-www-form-urlencoded">
                        <div class="form-group">
                          <label for="username">Email</label>
                          <input type="text" name="user_email" class="form-control" placeholder="Enter Email">
                        </div>'
                        .$registration->errors['user_email_error'].'
                        <div class="form-group">
                          <label for="user_question">Recovery Question: 
                            <select name="user_question" class="form-control">
                              <option value="" selected="selected">select Recovery Question</option>
                              <option value="1">My pets name</option>
                              <option value="2">Mothers maiden name</option>
                              <option value="3">My First car</option>
                              <option value="4">My favourite uncle\'s name</option>
                              <option value="5">My favourite childs name</option>
                            </select>
                          </label>
                          '.$registration->errors['recovery_question'].'
                        </div>
                        <div class="form-group">
                          <label for="user_answer">Answer: 
                            <input type="text" name="user_answer" class="form-control"/>
                            '.$registration->errors['recovery_answer'].'
                          </label>
                        </div>
                        <div>
                          <input type="submit" name="verify_me" value="Verify Me" class="btn btn-success btn-block" style="font-size:18px; font-weight:900" />
                        </div>
                      </form>
                    </div>
                    <div class="col-xs-1 col-sm-3 col-md-3 col-lg-4"></div>
                </div>
                <!-- /.row -->

            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->';
}
if(!isset($_SESSION['user_email']) && isset($_SESSION['user_reset'])){
    echo '<!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
            <div class="collapse navbar-collapse navbar-ex1-collapse">
                <ul class="nav navbar-nav side-nav">
                    <li class="active"><a href="./">Login</a></li>
                    <li><a href="./?reg">Sign Up</a></li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
    </nav>
        <div id="page-wrapper">

            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Password Reset
                        </h1>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Password Reset
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <div class="row">   
                    <div class="col-xs-1 col-sm-3 col-md-3 col-lg-4"></div>
                    <div class="col-xs-10 col-sm-6 col-md-6 col-lg-4" style="margin-bottom:200px">'
                      .$registration->messages['recovery_reset_successful'].'
                      <form method="post" enctype="application/x-www-form-urlencoded">
                        <input type="hidden" name="user_email" value="'.$_SESSION['user_reset'].'">
                        <div class="form-group">
                          <label for="username">New Password</label>
                          <input type="text" name="user_password" class="form-control" placeholder="Enter New Password">
                        </div>
                        <div class="form-group">
                          <label for="username">Repeat Password</label>
                          <input type="text" name="user_password_repeat" class="form-control" placeholder="Repeat New Password">
                        </div>'
                        .$registration->errors['user_password_error'].''
                        .$registration->errors['user_password_repeat_error'].'
                        <div>
                          <input type="submit" name="password_rest" value="Reset Password" class="btn btn-success btn-block" style="font-size:18px; font-weight:900" />
                        </div>
                      </form>
                    </div>
                    <div class="col-xs-1 col-sm-3 col-md-3 col-lg-4"></div>
                </div>
                <!-- /.row -->

            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->';
}
if(!isset($_SESSION['user_email']) && isset($_GET['reg'])){
    echo '<!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
            <div class="collapse navbar-collapse navbar-ex1-collapse">
                <ul class="nav navbar-nav side-nav">
                    <li><a href="./">Login</a></li>
                    <li class="active"><a href="./?reg">Sign Up</a></li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
    </nav>
        <div id="page-wrapper">

            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Sign Up

                        <div class="alert alert-warning alert-dismissable">
                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>


                <div class="row">
                    <div class="col-lg-12">
                        <div class="alert alert-info alert-dismissable">
                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                            <i class="fa fa-info-circle"></i>  <strong>Please we advice you have your mobile banking available to you in order to avoid being removed from the system due to inability to pay in 24 hours.
                        </div>
                    </div>
                </div>
                <!-- /.row -->

                <div class="row">
                    <div class="col-xs-12 col-sm-10" style="padding-top:30px; padding-bottom:5px">
                      '.$registration->messages['success'].'
                      '.$registration->errors['registration_error'].'
                      <form method="post">
                        <label for="mobile_number">Phone: 
                          <input type="text" name="mobile_number" class="form-control" />
                          '.$registration->errors['mobile_number_error'].'
                        </label><br />
                        <label for="user_email">Email: 
                          <input type="email" name="user_email" class="form-control"/>
                          '.$registration->errors['user_email_error'].'
                        </label><br />
                        <label for="user_password_new">Password: 
                          <input type="password" name="user_password_new" class="form-control"/>
                          '.$registration->errors['user_password_error'].'
                        </label><br />
                        <label for="user_password_repeat">Repeat Password: 
                          <input type="password" name="user_password_repeat" class="form-control" />
                          '.$registration->errors['user_password_repeat_error'].'
                        </label><br />
                        <label for="user_amount">Amount to Cycle: 
                          <select name="user_amount" class="form-control">
                            <option value="" selected="selected">Amount to cycle</option>
                            <option value="10,000">N 10,000</option>
                            <option value="20,000">N 20,000</option>
                            <option value="50,000">N 50,000</option>
                            <option value="100,000">N 100,000</option>
                          </select>
                          '.$registration->errors['user_amount_error'].'
                        </label><br />
                        <label for="user_name">Account Name(Name As it shows in your account): 
                          <input type="text" name="user_name" class="form-control"/>
                          '.$registration->errors['user_name_error'].'
                        </label><br />
                        <label for="user_account_number">Account Number: 
                          <input type="number" name="user_account_number" class="form-control"/>
                          '.$registration->errors['user_account_number_error'].'
                        </label><br />
                        <label for="user_bank_name">Bank Name: 
                          <input type="text" name="user_bank_name" class="form-control"/>
                          '.$registration->errors['user_bank_name_error'].'
                        </label><br />
                        <label for="email">Country: 
                          <select name="country" class="form-control">
                            <option value="Nigeria" selected="selected">Nigeria</option>
                          </select>
                          '.$registration->errors['country_error'].'
                        </label><br />
                        <label for="user_question">Recovery Question: 
                          <select name="user_question" class="form-control">
                            <option value="" selected="selected">select Recovery Question</option>
                            <option value="1">My pets name</option>
                            <option value="2">Mothers maiden name</option>
                            <option value="3">My First car</option>
                            <option value="4">My favourite uncle\'s name</option>
                            <option value="5">My favourite childs name</option>
                          </select>
                        </label><br />
                          '.$registration->errors['recovery_question'].'
                        <label for="user_answer">Answer: 
                          <input type="text" name="user_answer" class="form-control"/>
                          '.$registration->errors['recovery_answer'].'
                        </label><br />
                        <img src="./php-login-advanced-master/tools/showCaptcha.php" alt="captcha" /><br />
                        <label for="captcha">Enter the captcha above
                          <input type="text" name="captcha" required class="form-control"/>
                        </label>
                          '.$registration->errors['captcha_error'].'<br />
                        <input type="submit" name="register" value="SIGN UP" class="btn btn-success"/>
                      </form>
';
}?>

Registration.php session part

public function __construct()
    {
        session_start();

        // if we have such a POST request, call the registerNewUser() method
        if (isset($_POST["register"])) {
            $this->registerNewUser($_POST['user_name'], $_POST['user_email'], $_POST['user_password_new'], $_POST['user_password_repeat'], $_POST["captcha"], $_POST['mobile_number'],$_POST['country'],$_POST['user_account_number'],$_POST['user_bank_name'],$_POST['user_question'],$_POST['user_answer'],$_POST['user_amount']);
        }
        // if we have such a POST request, call the verifyUser() method
        if (isset($_POST["verify_me"])) {
            $this->verifyUser($_POST['user_email'], $_POST['user_question'], $_POST['user_answer']);
        }
        // if we have such a POST request, call the reset_recovery() method
        if (isset($_POST["reset_recovery"])) {
            $this->reset_recovery($_POST['user_email'], $_POST['user_question'], $_POST['user_answer']);
        }
        // if we have such a POST request, call the reset_recovery() method
        if (isset($_POST["password_rest"])) {
            $this->reset_password($_POST['user_email'], $_POST['user_password'], $_POST['user_password_repeat']);
        }
    }

Session was also stated in the login file...

This is the error message i get:

PHP Notice:  A session had already been started - ignoring session_start() in php-login-advanced-master/classes/Registration.php on line 39
PHP Notice:  Use of undefined constant user_name - assumed 'user_name' in index.php on line 125
PHP Notice:  Undefined index: user_name in index.php on line 125
PHP Notice:  Undefined index: recovery_reset_successful in index.php on line 272
PHP Notice:  Undefined index: invalid_email in index.php on line 278
PHP Notice:  Undefined index: Login_failed in index.php on line 283
PHP Notice:  Undefined index: wrong_password in index.php on line 283
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么