Al Mukminin Al Mukminin - 3 months ago 9
PHP Question

how to hide this notice

i just want to ask how to hide this below notice.

Notice: A session had already been started - ignoring session_start() in C:\xampp\secxampp\htdocs\MKSFINALASD\web\check.php on line 2

my first code is check1.php

<?php
session_start();
if(isset($_SESSION['username']))
include ("preorder.php");
else
include("login.php");
?>


this is my sec code check.php.

<?php
session_start();
if(isset($_SESSION['username']))
include ("top2.php");
else
include("top.php");
?>


the problem start when i click book now button in this code



<!--
Author: W3layouts
Author URL: http://w3layouts.com
License: Creative Commons Attribution 3.0 Unported
License URL: http://creativecommons.org/licenses/by/3.0/
-->
<!DOCTYPE HTML>

<html>
<head>
<title>Free Web-Hosting Website Template | Website-Builder :: w3layouts</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
<?php
include("check.php");
?>
<div class="blue-bar">
<div class="wrap">
<div class="host-content">
<div class="plans-masthead" style="overflow:visible;">
<h2>CAR GRAB <em>Service</em></h2>
<ol>
<li>Easy To Make A Booking </li>
<li>Fast Respond Within 15 Minutes</li>
<li>Dadicated driver with license and certificate</li>
</ol>
</div>
<div class="linux-banner">
<img src="images/car.gif" style="top:15px;" />
</div>
<div class="clear"></div>
<div class="row-indent">
<h2 class="h2-subheading">Select Your <em>DESTINATION</em></h2>
</div>
<div class="host-main">
<div class="plans-columns-wrp">
<div class="grids-hosting">
<ul class="plan-list us_plan ">
<form name="hostingplan" id="hostingplan_4" method="POST">
<img src="images/download.jpg" style="top:15px;" />
<li class="p-name"><span class="pl-title">KTM&nbsp;<span style="border-left: 2px ridge #2396FF; padding:4px 0;">&nbsp;TANGJUNG MALIM<sub></sub></span><b></b></span></li>
<li class="p-feat">Web Space - 3 GB</li>
<li class="p-feat1">Get a base Website</li>
<li class="p-feat">Unlimited Data Transfer</li>
<li class="p-dropdown">
<select name="duration">
<option value="1"> 1 Year at <span class=WebRupee>$.</span> 50/month </option>
</select>
</li>
<li class="p-button"><a class="txt-button" href="check2.php">BOOK NOW</a></li>
</form>
</ul>
<ul class="plan-list us_plan ">
<form name="hostingplan" id="hostingplan_4" method="POST">
<img src="images/baru.jpg" style="top:15px;" />
<li class="p-name"><span class="pl-title">NEW&nbsp;<span style="border-left: 2px ridge #2396FF; padding:4px 0;">&nbsp;CAMPUS<sub></sub></span><b></b></span></li>
<li class="p-feat">Web Space - 3 GB</li>
<li class="p-feat1">Get a base Website</li>
<li class="p-feat">Unlimited Data Transfer</li>
<li class="p-dropdown">
<select name="duration">
<option value="1"> 1 Year at <span class=WebRupee>$.</span> 50/month </option>
</select>
</li>
<li class="p-button"><a class="txt-button" href="check2.php">Buy Now</a></li>
</form>
</ul>
<ul class="plan-list us_plan ">
<form name="hostingplan" id="hostingplan_4" method="POST">
<img src="images/lama.jpg" style="top:15px;" />
<li class="p-name"><span class="pl-title">OLD&nbsp;<span style="border-left: 2px ridge #2396FF; padding:4px 0;">&nbsp;CAMPUS<sub></sub></span><b></b></span></li>
<li class="p-feat">Web Space - 3 GB</li>
<li class="p-feat1">Get a base Website</li>
<li class="p-feat">Unlimited Data Transfer</li>
<li class="p-dropdown">
<select name="duration">
<option value="1"> 1 Year at <span class=WebRupee>$.</span> 50/month </option>
</select>
</li>
<li class="p-button"><a class="txt-button" href="check2.php">Buy Now</a></li>
</form>
</ul><br><br><br>
<ul class="plan-list us_plan plan-featured">
<form name="hostingplan" id="hostingplan_5" method="POST">
<img src="images/images.jpg" style="top:15px;" />
<li class="p-name2"><span class="pl-title">TOWN&nbsp;<span style="border-left: 2px ridge rgb(240, 180, 94); padding:4px 0;">&nbsp;TANGJUNG MALIM<sub></sub></span><b></b></span></li>
<li class="p-feat">Web Space - 20 GB</li>
<li class="p-feat1">Everything need your site</li>
<li class="p-feat">Depending on your Business</li>
<li class="p-dropdown">
<select name="duration">
<option value="1"> 1 Year at <span class=WebRupee>$.</span> 500.00/month </option>
</select>
</li>
<li class="p-button"><a class="txt-button" href="check2.php">Buy Now</a></li>
</form>
</ul>
</div>

</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
display_preferred_server_location("us");
var left= ($(".plans-columns-wrp").width()/2 )-($(".server_loc_tabs").width()/2);
$(".server_loc_tabs").css('left', left + 'px');

$(".server_loc_tabs li").click( function(){
$(".server_loc_tabs li").removeClass('sel');
$(this).addClass('sel');
$('.sel_tab').remove();
$(this).append("<div class='sel_tab'></div>");
$('#plans-container input[type=radio]').removeAttr("checked");
})

$('.country_specific_tabs li').each(function() {
add_event_to_tabs($(this).attr('country'));
});
});

function add_event_to_tabs(country){
$(".tab_" + country).click( function(){
var sel_tab_left=($(this).outerWidth()/2 );
$(".server_loc_tabs li .sel_tab").css('left', sel_tab_left + 'px');
var location = $(this).attr('country').toLowerCase();
$('.plan-list').hide();
$('.' + location + '_plan').show();
})
}

function display_preferred_server_location(location){
$('.plan-list').hide();
$(".tab_" + location.toUpperCase()).addClass('sel').append("<div class='sel_tab'></div>");
$('.' + location + '_plan').show();
$('#' + location.toUpperCase() + '_plan_check').attr('checked', 'checked');
}
</script>
</div>
</div>
</div>
<?php
include("bottom.html");
?>
</body>
</html>





then the notice will appear in this site.



<!--A Design by W3layouts
Author: W3layout
Author URL: http://w3layouts.com
License: Creative Commons Attribution 3.0 Unported
License URL: http://creativecommons.org/licenses/by/3.0/
-->
<!DOCTYPE HTML>

<html>
<head>
<title>Free Web-Hosting Website Template | Login :: w3layouts</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="all"/>
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
<?php
include("check.php");
?>
<div class="bulk-domain">
<div class="content">
<div class="wrap">
<div class="login_form">
<div class="login_form_left">
<h3>Sign in to make a booking!</h3>
<form method="post" action="loginproc.php">
<table>
<tbody><tr><td><div><label>Username <span class="astrix">*</span></label><input type="text" value="" name="username" id="username"></div>
<div><label>Password <span class="astrix">*</span></label><input type="password" value=""name="password" id="password"></div></td></tr>
<tr><td><label style="display:inline">Remember Me</label><input type="checkbox" value=""></td><td><span><a href="#">Forgot Password ?</a></span></td></tr>
<tr><td><input name="Checkout" type="submit" class="uiButton" value="Sign In"></td></tr>
</tbody></table>
</form>
</div>
<div class="login_form_right">
<h3>Don't have a account?</h3>
<div><a href="create-account.php"><button type="submit" name="submit" class="uiButton" id="new_submit">Create an Account in 5 minutes</button></a></div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<?php
include("bottom.html");
?>
</body>
</html>




Answer

Replace all session_start() with the following check:

if (session_status() == PHP_SESSION_NONE) {
    session_start();
}