Warning: Cannot modify header information Cant Fix [duplicate] - php

This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 5 years ago.
I've already looked at a ton of fixes for this I've tried deleting whitespace but there was none, I've tried using the ob_start(); function but to no avail. Whatever I do it gives me this error.
Warning: Cannot modify header information - headers already sent by
(output started at /home/gener105/public_html/header.php:37) in /home/gener105/public_html/includes/vault_post.inc.php on line 12
It says the output starts on the last line of my header.php file(Fig1) and it has a problem with me calling header(); in the function I need to use. This is because of me using the header(); function on line 12 in vault_post.inc.php(Fig2).
I'm just confused on why its doing this because theres no outputs before the the header is called.
FIG1 (header.php)
<?php
session_start();
include 'includes/dbh.php';
include 'includes/vault_post.inc.php';
date_default_timezone_set('America/New_York');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Generation Diary - Leave Them Something For Later</title>
<!-- Bootstrap Core CSS -->
<link href="lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="lib/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Cabin:700" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
<!-- Theme CSS -->
<link href="css/grayscale.min.css" rel="stylesheet">
<!-- Temporary navbar container fix until Bootstrap 4 is patched -->
<style>
.navbar-toggler {
z-index: 1;
}
#media (max-width: 576px) {
nav > .container {
width: 100%;
}
}
</style>
</head>
FIG2 (vault_post.inc.php) The first function thats needed in the file
<?php
function setVaultPosts($conn) {
if (isset($_POST['vault_sub'])) {
$uid = $_POST['uid'];
$date = $_POST['date'];
$content = $_POST['content'];
$sql = "INSERT INTO vaults (uid, date0, content) VALUES ('$uid', '$date', '$content')";
$result = mysqli_query($conn, $sql);
header("Location: http://www.generationdiary.com/user_vault.php?success");
}
}
FORM THAT NEEDS THE FUNCTION
<?php include('header.php'); ?>
<div class="container" id="vault_main">
<div class="row row-offcanvas row-offcanvas-right">
<div class="col-12 col-md-9">
<p class="float-right hidden-md-up">
<button type="button" class="btn btn-primary btn-sm" data-toggle="offcanvas">Toggle nav</button>
</p>
<div class="jumbotron">
<h1 class="text-center">
<?php
if (isset($_SESSION['username'])) {
echo $_SESSION['firstname'] . " " . $_SESSION['lastname'] . "'s";
} else {
echo "You are not logged in";
}
?>
</h1>
<h2 class="text-center">Vault</h2> </div>
<?php
if (isset($_SESSION['username'])) {
echo "
<form action='".setVaultPosts($conn)."' method='POST'>
<input type='hidden' name='uid' value='".$_SESSION['username']."'>
<input type='hidden' name='date' value='".date(' Y-m-d ')."'>
<textarea class='ckeditor' name='content'></textarea>
<br>
<button class='btn btn-default btn-lg' type='submit' name='vault_sub'>Submit</button>
";
getVaultPosts($conn);
} else {
echo "log in";
}
?>
</div>
<div class="col-6 col-md-3 sidebar-offcanvas" id="sidebar">
<div class="fixed">
<div class="list-group"> Vault Recipient Settings Account Settings Log Out </div>
</div>
</div>
</div>
</div>
<?php include('footer.php'); ?>

This is entirely obvious. And your code is entirely flawed and this is probably because you are using HTML form submission for the first time.
Your header.php includes HTML text which is sent out immediately. So you want to call your Header() function, you need to make sure nothing is sent out before hand. You are having your session_start() on the first line of your code, this is correct and you need to make sure that this function is the first line of code in any PHP script processing that is using it. You need to be careful that no header info is sent before this function is called.
HTMl form's action attribute is the url path, not the PHP function.
<form action='form_process.php'>. You set the path here the same way you set link's href (relative or absolute path). Your form_process.php will then receive a $_POST global variable for you to handle your form data received. http://php.net/manual/en/reserved.variables.post.php

Related

website layout changes if someone adds /randomcharacters after the given url

So im quiet new to coding in general and i started making a shop page where everything is dynamiclly put throught databases . Now the thing is that for example i have created index.php file where user would directly go to and from there he can choose his next category or whatever hes looking for.
Now the issue is that if someone does like index.php/asfjasflk , the index page will render and there's missing photos / links and so on , so the thing is how to prevent that from happening even if they input something to re direct them to main website or where they are.
To show you more what im talking about.
Index normally index when someone puts something
I have a free host because i wanted to test the .htaccess file as ive seen around but it seems not working , yes i have set Rewrite to on , i set 404 page custom but it still recognizes the default one or doesnt recognize it at all .
http://agcomputers.onlinewebshop.net/index.php - this is the main file and if you do http://agcomputers.onlinewebshop.net/index.php/asfkjasfklajsfas - You still get the main file but its empty and the url is re writen if i click on other links.
Here's the loginPage code.
Note: This happens with all the pages / files in my folder/website.
require_once("../includes/db.php");
require_once("../includes/sessions.php");
require_once("../includes/functions.php");
?>
<?php
if(isset($_SESSION['User_ID']))
{
Redirect_to("dashboard.php");
}
if(isset($_POST['submit']))
{
$adminUser = $_POST['username'];
$adminPassword = $_POST['password'];
if(empty($adminUser) || empty($adminPassword))
{
$_SESSION['ErrorMessage'] = "Emri ose Passwordi eshte bosh";
Redirect_to("login.php");
}
else
{
if(CheckUsernameExistsOrNot($adminUser) == true)
{
$found_account = LoginAttempt($adminUser, $adminPassword);
if($found_account)
{
if(password_verify($adminPassword, $found_account['password']))
{
$_SESSION['User_ID'] = $found_account['id'];
$adminUser = $_SESSION['adminName'] = $found_account['adminName'];
$_SESSION['SuccessMessage'] = "Welcome $adminUser";
if(isset($_SESSION['TrackingURL']))
{
Redirect_to($_SESSION['TrackingURL']);
}
else
{
Redirect_to("dashboard.php");
}
}
else
{
$_SESSION['ErrorMessage'] = "Passwordi nuk eshte i sakt";
Redirect_to("login.php");
}
}
else
{
$_SESSION['ErrorMessage'] = "Username ose Passwordi eshte gabim";
Redirect_to("login.php");
}
}
else
{
$_SESSION['ErrorMessage'] = "Username nuk ekziston ne databaze";
Redirect_to("login.php");
}
}
}
?>`
`
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../css/styles.css">
<script src="https://kit.fontawesome.com/496fd68b03.js" crossorigin="anonymous"></script>
<title>AG Computers</title>
</head>
<body>
<!-- SideBar Start -->
<div class="main-container d-flex">
<div class="content">
<!-- Dashboard Content -->
<div class="dashboard-content px-3 pt-4">
<div class="container container-fluid">
<div class="row ">
<div class="offset-1 col-lg-8 " >
<div class="card login-form mt-2 mb-2 p-4" style="top: 90%; ">
<?php
echo ErrorMessage();
echo SuccessMessage();
?>
<form action="login.php" method="post">
<div class="card-header">
<h3 class="text-white">Login</h3>
</div>
<label class="text-white" for="username">Username:</label>
<input type="text" id="username" name="username" class="form-control">
<label for="password" class="text-white mt-2">Password:</label>
<input type="password" id="password" name="password" class="form-control ">
<button class="btn btn-outline-info text-black form-control mt-2" type="submit" name="submit">Login</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div><!-- Content Div -->
</div> <!-- Main Flex Container Div -->
<!-- FOOTER -->
<footer class="text-white" style="background-color: #000;">
<div class="container ">
<div class="row d-none d-md-block">
<p class="lead text-center">Theme by <span id="year"></span></span> © --- All Rights Reserved</p>
</div>
</div>
</footer>
<!-- End FOOTER -->
<!-- Dashboard Content End -->
<!-- SideBar End -->`
`<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js"></script>
<script type="text/javascript">
$('.sidebar ul li').on('click', function(){
$('.sidebar ul li.active').removeClass('active');
$(this).addClass('active');
});
$('.open-btn').on('click', function(){
$('.sidebar').addClass('active');
});
$('.close-btn').on('click', function(){
$('.sidebar').removeClass('active');
});
</script>
</body>
</html>``
I tried to put up .htaccess and that did not work aswell
You are currently calling the CSS via this code :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/styles.css">
You should change the link from relative path (href="css/styles.css")
To absolute Path (href="/css/styles.css" , or something similar depending on how your folders are organised)
otherwise, when adding a slash at the end of the URL, your code will try to get the CSS from http://agcomputers.onlinewebshop.net/index.php/styles.css, when it should be http://agcomputers.onlinewebshop.net/styles.css (again, could be different depending on how you organised your folders)
hope it helps
Edit : mistyped ./ instead of / before absolute path
Second Edit : just double checked and it seems the CSS is not the only problem, you are also calling the folders "images" and "uploads" via relative paths, which should be changed as well.
example of a wrong call of the uploads folder
uploads relative path call
Simply Put this Redirect in your Page if Someone visit it with extra Params it will redirect to vase file.
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$base_url = 'http://' . $_SERVER['SERVER_NAME'].'/'.basename(__FILE__);
if($url != $base_url)
{
header("Location:$base_url");
}

Cannot modify header information error? [duplicate]

This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 5 years ago.
IK this is prob a dupe, but I cant find any solutions to my code what so ever, no matter what code i add/change, it just wont budge... (NOTE im not using normal php, using a friends version, which yes, is fine and dandy)
<?php
include($_SERVER['DOCUMENT_ROOT'].'/phpAlphaDB/core.php');
?>
<html>
<head>
<link rel="icon" type="image/png" href="../logo.png">
<title> Xenoz Web - Users </title>
<link rel="stylesheet" type="text/css" href="../css/style.php" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<?php
if ($role==0) {
header('Location: http://xenozweb.tk/index.php');
} else {
echo '<script>alert("Hello, '.$username.'. Welcome to the userlist...");</script>';
}
?>
<body>
<div class="navigation">
<div class="navitem"> Home </div>
<div class="navitem"> Register </div>
<div class="navitem"> Login </div>
<div class="navitem"> Users </div>
<div class="navitem"> Jukebox </div>
</div>
</div>
<div class="pagecontent">
<div class="userblock">
<?php
$results = db_read('xenozweb-users', '', 'username');
foreach ($results as $result) {
$u_name = db_column($result, 0);
echo '<div class="users">',$u_name,'</div>';
}
?>
</div>
</div>
</body>
</html>
You're returning a partial response before you set the header. Headers must be sent before a response is sent back to the browser.
Try moving the header('Location: ') function call into the top <?php enclosure like so:
<?php
include($_SERVER['DOCUMENT_ROOT'].'/phpAlphaDB/core.php');
if ($role==0) {
header('Location: http://xenozweb.tk/index.php');
}
?>
<html>
<head>
<link rel="icon" type="image/png" href="../logo.png">
<title> Xenoz Web - Users </title>
<link rel="stylesheet" type="text/css" href="../css/style.php" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<?php
if ($role != 0) {
echo '<script>alert("Hello, '.$username.'. Welcome to the userlist...");</script>';
}
?>
</head>
<body>
You've already sent data to the browser. you cannot send header() info properly once you've already started to send data payload.

PHP relocation header not working [duplicate]

This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 7 years ago.
I have programmed a web application, which requires you to login first, before having access to the actual content of the application.
I am setting the value 'logedIn' to false when a user enters the homepage like this:
<?php
$_SESSION['logedIn'] = "false";
?>
If the user tries to go to overview.php, the code checks if the value of logedIn equals 'true'. If it is not, a header relocates the window to the login page like this:
<?php
session_start();
?>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://jquery-ui.googlecode.com/svn-history/r3982/trunk/ui/i18n/jquery.ui.datepicker-nl.js"></script>
<script src="../javascript/overview.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../css/mainpage.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
</head>
<body>
<?php
if($_SESSION['logedIn'] != "true") {
header("Location: ../index.php");
exit();
}
?>
<div class="container-fluid z-container">
<div class="row z-overview-top-menu">
<div class="col-md-2 z-background-dark z-top-nav z-border-right" id="menu_logo">
<h3>Logo</h3>
</div>
<div class="col-md-2 z-top-nav z-item-hover z-border-right z-selected" id="menu_diary" onclick="changeMenu('diary')">
<h3>Dagboek</h3>
</div>
<div class="col-md-2 z-top-nav z-item-hover z-border-right" id="menu_pazo" onclick="changeMenu('pazo')">
<h3>Pazo</h3>
</div>
<div class="col-md-2 z-top-nav z-item-hover z-border-right" id="menu_counter" onclick="changeMenu('counter')">
<h3>Tellers</h3>
</div>
<div class="col-md-2 z-top-nav z-item-hover z-border-right" id="menu_overview" onclick="changeMenu('overview')">
<h3>Overzicht</h3>
</div>
<div class="col-md-2 z-top-nav z-item-hover" id="menu_comparison" onclick="changeMenu('comparison')">
<h3>Vergelijking</h3>
</div>
</div>
<div class="row">
<div class="col-md-2 z-overview-left-menu">
<ul class="z-left-list" id="userList"></ul>
</div>
<div class="col-md-10 z-overview-main-menu">
<ul id="overviewList" class="z-overview-list-main">
</ul>
</div>
</div>
</div>
</body>
When I replace the header with an echo, I get a response, indicating that the header is indeed executing when I run the code.
Also there are no .htaccess in any of the directories.
Any thoughts on what the problem might be?
http://php.net/manual/en/function.header.php
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
Since you are outputting:
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://jquery-ui.googlecode.com/svn-history/r3982/trunk/ui/i18n/jquery.ui.datepicker-nl.js"></script>
<script src="../javascript/overview.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../css/mainpage.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
</head>
<body>
before the header call, it will fail.

Dynamically generated "submit" buttons in PHP

First time posting here (so please be gentle, as I am a relative PHP newbie).
I am building an intranet for our company and one of the things I need to do is to create a form that lists all outstanding sales orders (pulled from our accounting database) and provides a "submit" button beside each one to create the relevant work order.
Here is the code:
<div class="report_column">
<div class="report_header">
<div class="report_column_title" style="width:150px;margin-left:5px">ship date</div>
<div class="report_column_title" style="width:200px">customer</div>
<div class="report_column_title" style="width:140px;text-align:right">item</div>
<div class="report_column_title" style="width:120px;text-align:right">quantity</div>
</div>
<?php
// Open connection
include 'includes/dbconnect.php';
// Perform query
$result = mysqli_query($con,"SELECT * FROM tSalOrdr ORDER BY dtShipDate ASC");
// Retrieve results
while($row = mysqli_fetch_array($result)) {
$order = $row['lId'];
if ($row['bCleared'] == 0) {
$shipdate = substr($row['dtShipDate'], 0,10);
$customer = $row['sName'];
$po = $row['sComment'];
echo '<div class="report_item" style="width:750px";>';
echo '<form class="form" action="index.php?page=form&item=create_work_order" method="POST">';
echo '<div class="report_item_date" style="width:120px">'.$shipdate.'</div>';
echo '<div class="report_item_name" style="width:530px">'.$customer;
echo '<input type="hidden" name="po" value="'.$po.'" />';
echo '<input type="submit" class="submit" style="height: 25px;width:100px;margin:0px;padding:0px;margin:0px" value="work order"/>';
echo '</div>';
$result2 = mysqli_query($con,"SELECT * FROM tSOLine WHERE lSOId=$order ORDER BY sDesc ASC");
while($row = mysqli_fetch_array($result2)) {
if ($row['dRemaining'] <> 0) {
echo '<div class="report_item_details">';
echo '<div class="report_item_item">'.$row['sDesc'].'</div>';
echo '<div class="report_item_quantity">'.$row['dRemaining'].'</div>';
echo '</div>';
}
}
echo '</form>';
echo '</div>';
}
}
// Close connection
mysqli_close($con);
?>
</div>
What happens when I do this is that the first "submit" button will, for some reason, send me back to "index.php". The other buttons will load the correct page, however, they do not POST the required value.
Is there something I am doing wrong or is this something that needs different methodology than what I am currently using? My research on this seems to indicate that perhaps I should use javascript or an array to deal with this, but, having never dealt with either, I am not sure how to proceed. Any pointers would be appreciated.
Thanks.
#maniteja: The index.php is as follows:
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<title></title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<link href="css/forms.css" rel="stylesheet" type="text/css" />
<link rel="icon" type="image/ico" href="favicon.ico" />
<script type="text/javascript" src="scripts/jquery-2.1.0.min.js" ></script>
<script type="text/javascript" src="scripts/tabcontent.js" ></script>
</head>
<body>
<!-- BEGIN MAIN CONTENT -->
<div id="wrapper">
<!-- BEGIN HEADER -->
<div id="header">
<img src="images/logo.jpg">
</div>
<!-- END HEADER -->
<!-- BEGIN MAIN MENU -->
<div id="leftcolumn">
<?php include 'includes/menu.php'; ?>
</div>
<!-- END MAIN MENU -->
<!-- BEGIN CONTENT FRAME -->
<div id="rightcolumn">
<div id="content_area">
<?php
if (isset($_GET['page']))
{$page = $_GET['page'];
include('pages/' . $page . '.php');}
else {include('pages/home.php');}
?>
</div>
</div>
<!-- END MAIN CONTENT -->
</body>
</html>
I've made seventeen other forms with it, so I don't think that it is the problem. I'm hoping that this is just a typo or a logic error on my part.
u can use
<button type='submit' class='' name='' onclick=''>Submit</button>
Try to do onclick. See my example below.
input type="button" name="submit" onclick='location.href="index.php?id=$id"'
AS far as I understand, you are making your forms go to index.php:
echo '<form class="form" action="index.php?page=form&item=create_work_order" method="POST">';
Can you explain what is your expected behavior when a button is pushed?

Error with this Modify Header [duplicate]

This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 7 years ago.
Just to give you a short background, I am working with a referral program and the main feature of it is referring someone.
In my website. I have registration page, login page, successful registration page, referral page and referral list.
For example, if you are a user, you have to register through registration page. If you successfully register on my page, the next page will be the successful registration page. There is a button there to go to the referral page to refer someone.
The problem I encounter is, I register as a new user. So definitely, I filled up all necessary information to registration page, after I successfully register, the next page after that is showing the successful registration page and in that page there is a button that once you click it, it will go to referral form page.
For example, I will now refer someone, so I filled up all information, so when I tried to submit my referral there is an error that prompt at my page
Can anyone tell me which line of my code is triggering this error:
Warning: Cannot modify header information - headers already sent by
(output started at
/home/thecommissioner/public_html/crm/include/Webservices/Utils.php:880)
in
/home/thecommissioner/public_html/crm/modules/Webforms/capture_old.php
on line 97
but the referral added on my referral list, so when I tried to refer again, this error won't show anymore... even if I refer several times, this error didn't show anymore. It just shows on the first referral try of a new created account. I don't know what the problem is.
This just shows on my first try to referring somebody, but after that, when I tried to refer more, this wont show anymore and I already added my referral. Can someone help me to figure this out?
I know there are several lessons there and I've already read different posts in stackoverflow about this and I'm still vague about it. And would you mind telling me what new code I can use instead of my current code? I cannot test if my page is working because of this.
Here's my code:
<!DOCTYPE html>
<?php
include('../include/dbconnection.php');
include('../include/functions.php');
if(!isset($_SESSION))
{
session_start();
}
$empid = $_SESSION['SESS_EMP_ID'];
$conid = $_SESSION['SESS_CONID'];
$fName = $_SESSION['SESS_FIRSTNAME'];
$lName = $_SESSION['SESS_LASTNAME'];
$contactNo = $_SESSION['SESS_CONTACT_NO'];
$mobile = $_SESSION['SESS_MOBILE'];
$email = $_SESSION['SESS_EMAIL'];
$bday = $_SESSION['SESS_BDAY'];
if($conid == '')
{
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.location.href='index.php';
</SCRIPT>");
}
else
{
//Nothing
}
?>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="../css/normalize.css">
<link rel="stylesheet" href="../css/skeleton.css">
<link rel="stylesheet" href="../css/successReg_style.css">
<link rel="icon" type="image/png" href="../images/cvglogo.png">
<link rel="short icon" href="../images/favicon.ico">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript"></script>
<link rel="stylesheet" href="../css/animate.css">
</head>
<body>
<!--Here the Header goes-->
<?php include('include/logoheader.php'); ?>
<!-- Overall Contect for Responsive Purposes-->
<div class="allcontent">
<div class="row">
<div class="twelve columns" style="margin-top:0%;">
<!-- Here the Main Content goes-->
<div="maincontent">
<center>
<h3>Congratulations and Welcome to the Circle!</h3>
<br>
<div class=" animated zoomIn socialmedia">
<ul>
<li>
<img class="logos" src="../images/tick.png">
</li>
</ul>
</div>
<!-- This is the welcome Introduction -->
<div class="welcome">
<p>Now that you’re part of the most awesome group on the planet, why not share the glory with your friends. There’s no happier
team
player than a team player with his friends.</p>
<span class="hit">Don’t be shy. Hit the button. Refer your friend!</span><br>
<!-- This is Just a GIF arrow down -->
<div class="demo-wrapper">
<div class="html5-dialog">
<div class="gif">
<img src="../images/scroll-down.gif">
</div>
<?php include('GlobalConstant.php'); ?>
<!-- But here goes the button for "I have someone in mind" -->
<a href="<?php echo employee_refer; ?>"><button class="navbutton">I have someone in mind</button>
</a>
</div>
</div>
</div>
</div>
</div>
<!-- Here the footer goes-->
<center><?php include("include/footer.php"); ?></center>
</body>
</html>
The error:
Warning: Cannot modify header information - headers already sent by
(output started at
/home/thecommissioner/public_html/crm/include/Webservices/Utils.php:880)
in
/home/thecommissioner/public_html/crm/modules/Webforms/capture_old.php
on line 97
just shows on my first attempt of referring then after that, when I referred more, the above warning/error didn't show again.
If those warning just shows on my first attempt of referring, why it doesn't show the next time I referring again? It just shows on my first try.
You need to send header before ANY output is sent. That means before that HTML, on top of page.
OR, as RamRider suggested, use output buffering.
Put
ob_start()
On very top of page and
ob_end_clean()
On very bottom
You need to put the session_start() function on top your code. Otherwise sometimes php will throw the exception headers already sent.
<?php
session_start();
include('../include/dbconnection.php');
include('../include/functions.php');
$empid = $_SESSION['SESS_EMP_ID'];
$conid = $_SESSION['SESS_CONID'];
$fName = $_SESSION['SESS_FIRSTNAME'];
$lName = $_SESSION['SESS_LASTNAME'];
$contactNo = $_SESSION['SESS_CONTACT_NO'];
$mobile = $_SESSION['SESS_MOBILE'];
$email = $_SESSION['SESS_EMAIL'];
$bday = $_SESSION['SESS_BDAY'];
if($conid == '')
{
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.location.href='index.php';
</SCRIPT>");
}
else
{
//Nothing
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="../css/normalize.css">
<link rel="stylesheet" href="../css/skeleton.css">
<link rel="stylesheet" href="../css/successReg_style.css">
<link rel="icon" type="image/png" href="../images/cvglogo.png">
<link rel="short icon" href="../images/favicon.ico">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript"></script>
<link rel="stylesheet" href="../css/animate.css">
</head>
<body>
<!--Here the Header goes-->
<?php include('include/logoheader.php'); ?>
<!-- Overall Contect for Responsive Purposes-->
<div class="allcontent">
<div class="row">
<div class="twelve columns" style="margin-top:0%;">
<!-- Here the Main Content goes-->
<div="maincontent">
<center>
<h3>Congratulations and Welcome to the Circle!</h3>
<br>
<div class=" animated zoomIn socialmedia">
<ul>
<li>
<img class="logos" src="../images/tick.png">
</li>
</ul>
</div>
<!-- This is the welcome Introduction -->
<div class="welcome">
<p>Now that you’re part of the most awesome group on the planet, why not share the glory with your friends. There’s no happier
team
player than a team player with his friends.</p>
<span class="hit">Don’t be shy. Hit the button. Refer your friend!</span><br>
<!-- This is Just a GIF arrow down -->
<div class="demo-wrapper">
<div class="html5-dialog">
<div class="gif">
<img src="../images/scroll-down.gif">
</div>
<?php include('GlobalConstant.php'); ?>
<!-- But here goes the button for "I have someone in mind" -->
<a href="<?php echo employee_refer; ?>"><button class="navbutton">I have someone in mind</button>
</a>
</div>
</div>
</div>
</div>
</div>
<!-- Here the footer goes-->
<center><?php include("include/footer.php"); ?></center>
</body>
</html>
If you are still experiencing the issue try ob_start() and ob_flush() .. Anyways this stackoverflow article about headers already sent is worth reading though Stackoverflow link

Categories