Jump to content

[SOLVED] Is this setting the cookie


madspof

Recommended Posts

Right well this is the code am using but i gt this warning when the page is loaded coudl this explain why i cannot see the cookie

Warning: Cannot modify header information - headers already sent by (output started at /www/110mb.com/i/m/p/a/c/t/-/y/impact-ye/htdocs/Login.php:4) in /www/110mb.com/i/m/p/a/c/t/-/y/impact-ye/htdocs/Login.php on line 11

<?php
$info = "random";
$user = $_POST['name'];
$pass = $_POST['pass'];
if( $user == "staff"){
if($pass == "password"){
$log = "you are now logged in";
setcookie ("info",$info,time()+1800);
}else
        { echo "your password is wrong";}
}
else{
$log = "you are mot logged in";
}

?>

and then later on in the html

<?php

echo $_COOKIE["info"];

echo "$log";

?>

Well i check that thing and it seems that my code is set out correctly i think but i still get errors

<?php
$info = "random";
$user = $_POST['name'];
$pass = $_POST['pass'];
if( $user == "staff"){
if($pass == "password"){
$log = "you are now logged in";
setcookie ("info",$info,time()+1800);
}else
        { echo "your password is wrong";}
}
else{
$log = "you are mot logged in";
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Impact. A Branch of Young Enterprise</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="/default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="header">
	<h1><a href="#">Impact</a></h1>
	<p>a young enterprise group </a></p>
</div>
<!-- end header -->
<div id="menu">
	<h2>Main Menu</h2>
	<ul>
		<li class="active"><a href="/index.html">Home</a></li>
		<li><a href="/products.html">Products</a></li>
		<li><a href="/services.html">Services</a></li>
		<li><a href="/forum.html">Forum</a></li>
		<li><a href="/support.html">Support</a></li>
		<li></li>
		<li><a href="/contact.html">Contact</a></li>
	    <a href="/members.html">members</a>
	</ul>
</div>
<!-- end menu -->
<div id="page">
	<div id="content">
		<h1>Welcome to Impact </h1>
		<p>
		<div align="center"><?php
echo $_COOKIE["info"];
echo "$log";
?></div>
		</p>
		<p> </p>
		<p> </p>
		<p> </p>
		<p> </p>
		<p> </p>
		<div class="boxed">
			<h2 class="title">LATEST NEWS </h2>
			<div class="content">
				<div>
                      <p>On the 11 of October 2007 this site was set up and is currently under   construction. </p>
				  <p> </p>
				  <p>Please be patient for the site to develop further. </p>
				  <p> </p>
				  <p>We are constantly updating and hopefully we will be fully active in a matter of weeks. </p>
				  <blockquote> </blockquote>
			  </div>
				<p> </p>
				<blockquote> </blockquote>
		  </div>
		</div>
  </div>
	<!-- end content -->
	<div id="sidebar">
		<ul>
			<li id="search">
				<form id="searchform" method="get" action="">
					<fieldset>
					<legend>Search</legend>
					<input id="searchfield" type="text" name="q" value="" />
					<input id="searchsubmit" type="submit" value="Search" />
					</fieldset>
				</form>
			</li>
			<li id="submenu">
				<h2>Other Links</h2>
				<ul>
				  <li>products will be here soon </li>
				  <li>
			        <ul>
			              <li>Services also </li>
		            </ul>
				  </li>
			    </ul>
		    </li>
			<li id="news"></li>
	      <li></li>
	      <li></li>
	      <li></li>
	      <li></li>
	      <li></li>
	      <li></li>
	      <li></li>
	      <li></li>
	      <li></li>
	      <li></li>
	      <li></li>
	      <li></li>
		    <li>
		      <h2>News & Updates</h2>
		      <ul>
		        <li>11 October 2007 </li>
                    <li>Site is up and running. </li>
                    <li>Currently undergoing construction. </li>
                    <li><p> </p>
                      </li>
                    </ul>
	      </li>
		</ul>
  </div>
	<!-- end sidebar -->
	<div style="clear: both;"> </div>
</div>
<!-- end page -->
<div id="footer">
	<p id="legal">Copyright © 2007 Impact. All Rights Reserved.</p>
	<p id="links">Privacy Policy | <a href="#">Terms of Use</a></p>
</div>
<!-- end footer -->
</div>
<!-- end wrapper -->
</body>
</html>

its coming from a html page called login.html and the code i have for the form is

<form method="POST" action="Login.php" name="login">Username:</td>
<td><input type="text" name="name" class="forminput" size="7"></td></tr>
<tr><td>Password:</td>
<td><input type="password" name="pass" class="forminput" size="7"></td></tr>
<tr><td colspan="2"><center><input type="submit" value="Login"></form>

try this :

 

ob_start();
<?php
$info = "random";
$user = $_POST['name'];
$pass = $_POST['pass'];
if( $user == "staff"){
if($pass == "password"){
$log = "you are now logged in";
setcookie ("info",$info,time()+1800);
}else
        { echo "your password is wrong";}
}
else{
$log = "you are mot logged in";
}
ob_finish();
?>

sorry the ob_start() inside <?php like this

<?php
ob_start();
<?php
$info = "random";
$user = $_POST['name'];
$pass = $_POST['pass'];
if( $user == "staff"){
if($pass == "password"){
$log = "you are now logged in";
setcookie ("info",$info,time()+1800);
}else
        { echo "your password is wrong";}
}
else{
$log = "you are mot logged in";
}
ob_finish();
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.