Showing Error
Warning: session_start() [function.session-start]: Cannot send session cookie -
headers already sent by (output started at
/home/content/82/11942882/html/praveen/Allyface/index.php:8) in
/home/content/82/11942882/html/praveen/Allyface/index.php on line 11
Warning: session_start() [function.session-start]: Cannot send session cache limiter - >headers already sent (output started at >/home/content/82/11942882/html/praveen/Allyface/index.php:8) in >/home/content/82/11942882/html/praveen/Allyface/index.php on line 11
index.php
<?php
//simple PHP login script using Session
//start the session * this is important
session_start();
//login script
if(isset($_REQUEST['ch']) && $_REQUEST['ch'] == 'login'){
//give your login credentials here
if($_REQUEST['uname'] != '' && $_REQUEST['pass'] != '')
{
$email=$_REQUEST['uname'];
$pass=$_REQUEST['pass'];
//echo $email.$pass;
include("db.php");
mysql_query("select * from users where email='$email' and pass='$pass' ");
if(mysql_affected_rows()>0)
{
$_SESSION['login_user'] = $email;
}
else
{
$_SESSION['login_msg'] = 1;
}
}
else
$_SESSION['login_msg'] = 1;
}
//get the page name where to redirect
if(isset($_REQUEST['pagename']))
$pagename = $_REQUEST['pagename'];
//logout script
if(isset($_REQUEST['ch']) && $_REQUEST['ch'] == 'logout'){
unset($_SESSION['login_user']);
header('Location:index.php');
}
if(isset($_SESSION['login_user'])){
if(isset($_REQUEST['pagename']))
{
?>
//header('Location:'.$pagename.'.php');
<script type="text/javascript">
self.location='<?php echo $pagename.'.php'; ?>';
</script>
<?php
}
else
{
$email=$_REQUEST['uname'];
?>
<script type="text/javascript">
self.location='<?php echo 'home.php'; ?>';
</script>
<?php
}
//header('Location:home.php');
}else{
?>
<form id="" name="form1" method="post" action="">
<table width="452" border="0">
<tr>
<td width="172"> <input name="uname" type="text" style="margin-top:15px; width:150px; height:22px; border:1px solid #CCCCCC; padding-left:30px;" placeholder="Email or Phone" />
</td>
<td width="177"> <input name="pass" type="password" style=" margin-top:15px; width:150px; height:22px; border:1px solid #CCCCCC; padding-left:30px;" placeholder="Password" />
</td>
<td width="81"><input name="login" type="submit" style=" margin-top:15px; background-color:#FFFF00;background-color: #fdd922; margin-left:30px;
border: 1px solid #e0bc27; font-weight:bold;
border-radius: 2px 2px 2px 2px; height:25px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color: #565656;" placeholder="login" value="Login" /></td>
</tr>
<tr>
<td colspan="3"><?php
//display the error msg if the login credentials are wrong!
if(isset($_SESSION['login_msg'])){
echo '<div style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#F00;">Wrong username and password !</div>';
unset($_SESSION['login_msg']);
}
?> </td>
</tr>
</table>
<input type="hidden" name="ch" value="login">
</form>
</div>
<?php }
?>
home.php
<?php
session_start();
//check logged in or not!
if(!isset($_SESSION['login_user'])){
?>
//header('Location:index.php?pagename='.basename($_SERVER['PHP_SELF'], ".php"));
<script type="text/javascript">
self.location='<?php echo 'index.php?pagename='.basename($_SERVER['PHP_SELF'],".php"); ? >';
</script>
<?php
}
else
{
include("db.php");
$uname=$_SESSION['login_user'];
$q=mysql_query("select * from users where email = '$uname'");
while($r=mysql_fetch_array($q))
{
$uid=$r['fname'];
?>
Please Help me
Thanks in advance
Make sure there is no data sent by the server before dealing with Sessions.
This includes White Spaces, Blank Lines or any type of data.
The point where output started is shown in the error message:
output started at /home/content/82/11942882/html/praveen/Allyface/index.php:8
It seems you have a "dispatcher" index.php, which loads other php files (like login.php). The reason for this error is something being printed in index.php on line 8.
If you see nothing printed on index.php, then there might be a newline at the end of file (if you are using Vi, it leaves a trailing new line on every file)
It's not possible to set cookies (or send any other headers) after output is started. You could add
ob_start()
at line 1 to buffer the output.
Related
Hello guys I am working on a freelance project and I faced with a problem I added some php codes in order to change paragraph elements visibility. the paragraph element which has to appear when user entered wrong username or password however paragraph element appears all the time
PHP SECTION
<?php
session_start();
require "db.php";
if ( !empty($_POST)) {
extract($_POST) ;
if ( checkUser($id, $pass) ) {
echo '<style>#wrong-password {display:none;margin-bottom: 5%;padding: 5%;width: 280px;font-family: "Montserrat", sans-serif;font-size: 1em;border-radius: 8px;border: 1px solid #ced4da;background-color: rgb(255, 23, 23);color: white;text-align: center;margin-top: 0;}</style>';
// you are authenticated
// session_start() creates a random id called session id.
// and stores in a cookie.
$_SESSION["user"] = getUser($id) ;
if($_SESSION["user"]["userType"]=='normal'){
header("Location: Analyzes.php?id=$id") ;
exit ;
}else {
header("Location: index.php") ;
exit ;
}
}
echo '<style> #wrong-password{visibility:visible; margin-bottom: 5%;padding: 5%;width: 280px;font-family: "Montserrat", sans-serif;font-size: 1em;border-radius: 8px;border: 1px solid #ced4da;background-color: rgb(255, 23, 23);color: white;text-align: center;margin-top: 0;}</style>';
}
HTML SECTION
<div id="form-container">
<h2>Ho艧geldiniz! 馃樅</h2>
<form action="?" method="POST">
<input type="number" name="id" placeholder="Kullan谋c谋 Numaras谋">
<br>
<input type="password" name ="pass" placeholder="Parola">
<p id="wrong-password">Kullan谋c谋 Ad谋 veya Parola Hatal谋 :(</p>
<button type="submit" title="Giri艧 Yap">Giri艧 Yap</button>
</form>
</div>
Thanks in advance:)
I am setting 2 session variables and then called the header function.
(SecurityCheck.php)
$_SESSION['danger'] = "true";
$_SESSION['priviledgeError'] = "You do not have access";
header('Location: index.php');
However, when the header re-directs to the proper page, only one of the sessions retains its value, even though I never called any type of session unset method.
(index.php)
echo 'line 63 index.php';
echo "<br>danger session is: " . isset($_SESSION['danger']);
echo "<br>priviledge session is: " . isset($_SESSION['priviledgeError']);
line 63 index.php
danger session is:
priviledge session is: 1
I have checked through all relevant files for any places I may have called an unset function, and made sure session_start() is appended to the top of both pages.
I expect that both sessions will return "1" and not just one of them.
Entire Index.php file:
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Sign-Up/Login Form</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/style2.css">
<style>
#userPass
{
padding; 20px;
}
#logIn
{
padding: 20px;
position:relative;
border-style: solid;
margin:auto;
background-color: white;
width: 390px;
height: 160px;
}
#log-in-header
{
position: absolute;
left:46%;
font-size: 35px;
color:black;
}
#submitButton
{
position: relative;
top: 83px;
width: 347px;
}
td
{
padding: 20px;
}
</style>
</head>
<!--ONLY runs when user has clicked LOG-IN-->
<body>
<div id='container'>
<?php
echo 'line 63 index.php';
echo "<br>danger session is: " . isset($_SESSION['danger']);
echo "<br>priviledge session is: " .
isset($_SESSION['priviledgeError']);
// die;
require 'header.php';
require 'messages.php';
?>
<br>
<p id='log-in-header'>
Log-In
</p>
<hr><br><br><br>
<form method="post" action="login.php">
<div id='logIn'>
<!-- <div id='userPass'>-->
<table style = "position: relative; bottom:
40px;">
<tr>
<td style='font-size: 20px'>Username:</td>
<td><input type="text" style='color:
black' name="userName" id='user' ></td>
</tr>
<tr>
<td style='font-size: 20px'>Password:</td>
<td><input type="password" style='color:
black' name="password" id='pass' ></td>
</tr?
</table>
<!-- </div>-->
<div id='submitButton'>
<input type="submit" class="btn btn-default"
style='color: black; font-size: 20px' value="Log In">
</div>
</div>
</form>
</div>
<!-- LOG-IN form ENDS -->
<!-- JS scrips-->
<script src="js/index.js"></script>-->
</body>
</html>`
UPDATE: added a new session entry, as well as a session deleteion to SecurityCheck.php
$_SESSION['danger'] = "true";
$_SESSION['priviledgeError'] = "You do not have access
unset($_SESSION['priviledgeError']);
$_SESSION['newSession'] = "hi";
header('Location: index.php');
Here is code in index.php:
echo 'line 63 index.php';
echo "<br>danger session is: " . isset($_SESSION['danger']);
echo "<br>priviledge session is: " .
isset($_SESSION['priviledgeError']);
echo "<br>new session is: " . $_SESSION['newSession'];
Here is result:
line 63 index.php
danger session is:
priviledge session is:
new session is: hi
I am getting a problem where my login details wont let me log into my page :(
so my set up page is
<?php
$db = mysql_connect("$host", "$dblogin", "$dbpassword");
mysql_select_db("$dbname");
$res = mysql_query("SELECT * FROM userdb WHERE email='$email'");
$playerinfo = mysql_fetch_array($res);
$date2 = date("H:i");
function error($type)
{
if($type == "field")
{
echo '<body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" bgcolor="#000000" text="#FFFFFF">';
echo '<p align=center><font color="red">You have left fields blank. Please relogin</font></center></p>';
}
elseif($type == "password")
{
echo '<p><center><font color="red">Incorrect password. Please relogin</font></center></p>';
}
}
echo '</body>';
?>
my login page is
<body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" bgcolor="#000000" text="#FFFFFF">
<p align="center">
<img border="0" src=logo.jpg></img></p>
<p align="center">
<form action=check.php method=post>
<p align="center"><font size=1><b><font face="Tahoma" size="2">Login.</font></b><br><br>
<samp style="font-weight: normal; font-size: 7pt; font-family: tahoma"><font face="Tahoma" size="2"><b>Email -</fomt></b></font></samp><font face="Tahoma" size="2"><b>
<input type="text" name="email" size="20" style="border: 1px solid black">
</b></font></font><font face="Tahoma" size="2">
<br>
<samp style="font-weight: normal; font-size: 7pt; font-family: tahoma">
<b><font face="Tahoma" size="2">Pass -</font></b></samp><b><font size="1" face="Tahoma"><input type="password" name="password" size="20" style="border: 1px solid black"></font></b><br><input type="submit" value="Log In" style="border: 1px solid black">
<br>
</form>
</body>
and my check.php page is
<?
session_start();
include("setup.php");
if(!$email || !$password) {
error("field");
exit();
}
if($password == $info['password']) {
session_register("password");
session_register("email");
include("top.php");
echo "<p><b><center>Welcome</center></b></p>";
echo "<p><u><b>Members Area</b></u></p>";
echo "<p><center>- <b><a href=>Page</a></b> -</center></p>";
echo "<p><center>- <b><a href=logout.php>Log Out</a></b> -</center></p>";
include("bottom.php");
}
else
{
error("password");
}
?>
I always get a error of You have left fields blank. Please relogin from my index page so I cannot get my user to log in
where have I failed?
I think you have not even set your variables :D That is why it is saying "You have left fields blank"
session_start();
include("setup.php");
After this include
$email = $_POST["email"];
$password = $_POST["password"];
Besides this : Use prepared statements to avoid SQL Injection
The problem may be this:
$db = mysql_connect("$host", "$dblogin", "$dbpassword");
I think you meant:
$db = mysql_connect("{$host}", "{$dblogin}", "{$dbpassword}");
You cannot include variables into a string without the {}.
But even in that case, you need to define those varaibles before this line.
$host = "ipaddress";
Also, once you get beyond that, you are treating strings as booleans:
if(!$email || !$password)
what is going on?
I recently installed and updated a site template , and designed it.
My friend had some site which he got on it a php login form, for users to log in.
I asked him for the code and he gave me it, and ofc I just copied the code and pasted it between my site template code.
I know u confused, so here's the deal:
This is a basic page on my site:
<?php
include('config.php');
if(MODULE == 'none')
{
include(LOVE_ROOT . '/system/love_head.php');
$content = '<h2> Welcome to OUR SITE </h2>
<br />
Hey this is a test
<br />
Hey this is a test
<br />
Hey this is a test
<br /> <br />
Hey this is a test
<br />
Hey this is a test
<br />
Hey this is a test
<br />
Hey this is a test
<br />
Hey this is a test
<br /> <br />
Welcome
<br />
Welcome to our site
<br />
Hey this is a test
<br /> <br /> <br />
';
include(LOVE_ROOT . '/system/love_foot.php');
}
else
{
header('Location: modules/' . MODULE);
}
?>
and here is the login form php code:
<?php
ob_start();
?>
<html dir="rtl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255" />
<style>
a:link,a:visited,a:active
{
background: transparent;
color: #000000;
text-decoration: none;
}
a:hover
{
background: transparent;
color: #00dfff;
}
td {
border: 1px solid gray;
padding: 5px;
text-align: center;
}
</style>
</head>
<center>
<?php
include('mysql.php');
$fname = $_POST['fname'];
$password = $_POST['pass'];
$pass1 = md5($password);
$pass = sha1($pass1);
$select = mysql_query("SELECT * FROM `users` WHERE fname='$fname'");
$cu = mysql_fetch_array($select);
if (!empty($_COOKIE['adv_U']) AND !empty($_COOKIE['adv_P']))
{
echo "讗转讛 讻讘专 诪讞讜讘专 诇转讞专讜转.";
}
else
{
if (!empty($username) || !empty($password))
{
if (empty($cu))
{
?>
<font color="darkred"><b>
砖讙讬讗讛 - 讛砖诐 讛驻专讟讬 砖讛讻谞住转 诇讗 拽讬讬诐 讘诪注专讻转
</b></font>
<br><br>
<input type="button" value="讞讝讜专 讗讞讜专讛" onclick="window.location.href='javascript:window.history.back(-1)';">
<?php
}
else if ($pass == $cu['password'])
{
if ($cu['ban'] == 1)
{
echo "<font color='red'><b>讗转讛 诪讜专讞拽 诪讛转讞专讜转 注拽讘 注讘讬专讛 注诇 讛讞讜拽讬诐!</b></font><br>讗转讛 诪讜讞讝专 诇讚祝 讛讘讬转 砖诇 讛诪注专讻转...";
echo "<meta http-equiv='refresh' content='3; url=index.php'>";
}
else
{
setcookie('adv_U',$fname);
setcookie('adv_P',$pass);
header( 'Location: index.php' );
}
}
else
{
?>
<font color="darkred"><b>
讛住讬住诪讗 砖讛讻谞住转 砖讙讜讬讛
</b></font>
<br><br>
<input type="button" value="讞讝讜专 讗讞讜专讛" onclick="window.location.href='javascript:window.history.back(-1)';">
<?php
}
}
else
{
?>
<form method="post" action="login.php">
<table>
<tr><td>砖诐 驻专讟讬</td><td><input type="text" name="fname"></td></tr>
<tr><td>住讬住诪讗</td><td><input type="password" name="pass"></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="讛转讞讘专讜转"></td></tr>
<tr><td colspan="2" align="center"><font size="2">(注讜讚 诇讗 谞专砖诪转?)</font></td></tr>
</table>
</form>
<?php
}
}
?>
</div>
</td>
</tr>
</table>
</body>
</html>
<?php
ob_end_flush();
?>
I tried to copy the php code between the headers of my page, to something like that:
<?php
include('config.php');
if(MODULE == 'none')
{
include(LOVE_ROOT . '/system/love_head.php');
$content = '<h2> Welcome to OUR SITE </h2>
<br />
<?php
ob_start();
?>
<html dir="rtl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255" />
<style>
a:link,a:visited,a:active
{
background: transparent;
color: #000000;
text-decoration: none;
}
a:hover
{
background: transparent;
color: #00dfff;
}
td {
border: 1px solid gray;
padding: 5px;
text-align: center;
}
</style>
</head>
<center>
<?php
include('mysql.php');
$fname = $_POST['fname'];
$password = $_POST['pass'];
$pass1 = md5($password);
$pass = sha1($pass1);
$select = mysql_query("SELECT * FROM `users` WHERE fname='$fname'");
$cu = mysql_fetch_array($select);
if (!empty($_COOKIE['adv_U']) AND !empty($_COOKIE['adv_P']))
{
echo "讗转讛 讻讘专 诪讞讜讘专 诇转讞专讜转.";
}
else
{
if (!empty($username) || !empty($password))
{
if (empty($cu))
{
?>
<font color="darkred"><b>
砖讙讬讗讛 - 讛砖诐 讛驻专讟讬 砖讛讻谞住转 诇讗 拽讬讬诐 讘诪注专讻转
</b></font>
<br><br>
<input type="button" value="讞讝讜专 讗讞讜专讛" onclick="window.location.href='javascript:window.history.back(-1)';">
<?php
}
else if ($pass == $cu['password'])
{
if ($cu['ban'] == 1)
{
echo "<font color='red'><b>讗转讛 诪讜专讞拽 诪讛转讞专讜转 注拽讘 注讘讬专讛 注诇 讛讞讜拽讬诐!</b></font><br>讗转讛 诪讜讞讝专 诇讚祝 讛讘讬转 砖诇 讛诪注专讻转...";
echo "<meta http-equiv='refresh' content='3; url=index.php'>";
}
else
{
setcookie('adv_U',$fname);
setcookie('adv_P',$pass);
header( 'Location: index.php' );
}
}
else
{
?>
<font color="darkred"><b>
讛住讬住诪讗 砖讛讻谞住转 砖讙讜讬讛
</b></font>
<br><br>
<input type="button" value="讞讝讜专 讗讞讜专讛" onclick="window.location.href='javascript:window.history.back(-1)';">
<?php
}
}
else
{
?>
<form method="post" action="login.php">
<table>
<tr><td>砖诐 驻专讟讬</td><td><input type="text" name="fname"></td></tr>
<tr><td>住讬住诪讗</td><td><input type="password" name="pass"></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="讛转讞讘专讜转"></td></tr>
<tr><td colspan="2" align="center"><font size="2">(注讜讚 诇讗 谞专砖诪转?)</font></td></tr>
</table>
</form>
<?php
}
}
?>
</div>
</td>
</tr>
</table>
</body>
</html>
<?php
ob_end_flush();
?>
<br /> <br /> <br />
';
include(LOVE_ROOT . '/system/love_foot.php');
}
else
{
header('Location: modules/' . MODULE);
}
?>
Of course I handled all the problems, deleted php tags where it's not neccessery, closed qoutes and etc..
but still.. it just won't work.
Sorry for my English,
Sorry for my lame knowledge,
please try and help a bummed guy who stuck with this problem already a week..
Thanks alot!
ALSO(!) I tried to fix it with NetBeans... but didn't manage.. lol I dont evenk now how this software works..
If I take the php code as it self, the original one, it works. If I take the original index file without anything else, it works.
When I add the code to the site template with the "love_foot" "love_head" and etc.. around the php login code, it tells me "unexpected T String".
So what is the problem here?
Thanks alot , I am so LOST right now!
You're missing the semicolon on Line 8. That's causing the rest of the PHP lines to be ignored.
Change it to:
$content = '<h2> Welcome to OUR SITE </h2><br />';
And around line ~127, you forgot to open the <? tag.
I believe that should fix the errors.
However you should use an IDE with syntax highlighting. That'll help you debug code faster.
Im having problem in my web where it works perfectly on my local server which is a WAMPSERVER i can run my website completely but after adding to the web server it give me error saying
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/multisl/public_html/udrivetest/index.php:2) in /home/multisl/public_html/udrivetest/init.php on line 4
init.php
<?php
ob_start();
session_start();
mysql_connect("localhost","***","***");
mysql_select_db('****');
include 'function/user.func.php';
include 'function/car.func.php';
include 'function/image.func.php';
?>
header1.php
<head>
<title></title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style4 {
font-size: 16px;
font-weight: bold;
}
.style5 {
font-size: 12px
}
.a {
color:#000000;
text-decoration:none;
}
-->
</style>
</head>
<body>
<div style="margin-left:10px;">U Drive.lk</div>
<div class="style5" style="text-align:right; padding:10px;">
Contact Us | Disclaimer | Site Map</div>
</div>
<div>
<div style="background-image:url(images/Car3.png); border:#FFFFFF; border-style:solid; border-width:2px; border-top:none; border-bottom:none; width:920px; height:450px; margin-left:auto; margin-right:auto;" align="center">
<br/>
<img src="images/Car6.png" width="920px" height="135px" />
<div style="margin-top:-22px; height:22px; margin-left:55px;" align="left"><a class="a">Home</a></div>
<div style="margin-top:-22px; height:22px; margin-left:200px;" align="left"><a class="a">Gallery</a></div>
<div style="margin-top:-22px; height:22px; margin-left:350px;" align="left"><a class="a">Leasing</a></div>
<div style="margin-top:-22px; height:22px; margin-left:490px;" align="left"><a class="a">Testimonial</a></div>
<div style="margin-top:-22px; height:22px; margin-left:640px;" align="left"><a class="a">Forum</a></div>
<div style="margin-top:-22px; height:22px; margin-left:790px;" align="left"><a class="a">FAQ</a></div>
<div style="margin-left:auto; margin-right:auto; margin-top:20px;" >
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','920','height','135','src','Flash/Flash Header2','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','Flash/Flash Header2' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="920" height="135">
<param name="movie" value="Flash/Flash Header2.swf" />
<param name="quality" value="high" />
<embed src="Flash/Flash Header2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="920" height="135"></embed>
</object></noscript>
</div>
<div align="left">
<table width="100%" border="0" style="margin-top:10px;">
<tr>
<td width="20%" valign="top" ><div align="left"><img src="images/Buy_men.png" /> <img src="images/Sell_men.png" /> <img src="images/Rent_men.png" /></div>
<div style="color:#FFFFFF;margin-top:-90px; width:38px; margin-left:10px;">Buy</div>
<div style="color:#FFFFFF;margin-top:-18px; width:38px; margin-left:65px;">Sell</div>
<div style="color:#FFFFFF;margin-top:-20px; width:38px; margin-left:115px;"><a style="color:#FFFFFF;">Rent</a></div></td>
<td width="38%"><fieldset style="background-color:#cccccc">
<span class="style4">Quick Search</span>
</fieldset></td>
<td width="42%"><fieldset style="background-color:#cccccc">
<span class="style4">Login</span>
<?php include_once('login.php'); ?>
</fieldset></td>
</tr>
</table>
</div>
</div>
</div>
<div style="margin-left:auto; margin-right:auto; width:920px;">
login.php
<?php
if (logged_in()) {
echo '<br/> View User Profile <br/>Log Out';
} else {
?>
<form action="" method="post">
<table width="100%" border="0" style="margin-top:-5px;" >
<tr>
<td><div align="left">User Name :</div></td>
<td><input type="text" name="Quick_Name" size="25" /></td>
</tr>
<tr>
<td><div align="left">Password :</div></td>
<td> <input type="text" name="PassWord" size="25" /> <input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
Forgot your password / Register User
<?php
}
if (isset($_POST['Quick_Name'], $_POST['PassWord'])) {
$forgotEmail = $_POST['Quick_Name'];
$login_password = $_POST['PassWord'];
if (empty($forgotEmail) || empty($login_password)) {
$errors[] = 'Email and Password required';
} else {
$login = login($forgotEmail, $login_password);
if ($login === false) {
$errors[] = 'Unable to Log you in';
}
}
if (!empty($errors)) {
foreach ($errors as $error) {
echo $error, '<br/>';
}
} else {
$_SESSION['user_id'] = $login;
header('Location:index.php');
exit();
}
}
?>
index.php
<?php include 'init.php'; include 'widgets/header1.php'; ?>
<div>
</div>
</div>
</body>
</html>
Please Can any one help me out to solve this problem or give me a clue what I am doing here?
Thanks in Advance
In PHP, headers get sent as soon as the page starts to print something - which can occur unintentionally due to whitespace.
Based on your error message (output started at /home/multisl/public_html/udrivetest/index.php:2)
I am guessing this line of index.php:
<?php include 'init.php'; include 'widgets/header1.php'; ?>
appears on line 2 of the file? But you cannot have a line of whitespace above it, it needs to be line 1 since one of the includes is dealing with headers (cookie for session).
Otherwise the blank line 1 is "printing something" - a new line - which sends headers probably before you are intending.
Basically, check all files for not having blank lines above opening tags <?php and don't have blank lines below closing tags ?>.
This is most likely that there exists some whitespace that is sent before the session_start command, try removing the closing PHP tag (?>) and report back the results.
By doing this you remove the possibility of it outputting any invalid whitespace.
There should have some blank space sending back to client. It is a good practise to leave php closing tag ?> if your last line of code is a php code.
Make sure that you dont leave any blank space before and after the php opening tag and php closing tag
You can prevent any output to send to client by using object buffering with ob_start() .
put the ob_start at the very beginning of your php code can save you time.
I would like to consider removing ob_start() from init.php to index.php.
thanks