Hi all,
i am trying to run the following HTML page which is the memebers area after the user login is sucesful the session is registered please check it and help me:-
HTML code:-

<!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>
  <style type='text/css'>
/* Text that follows the spinning cursor */
#outerCircleText {
font-style: italic;
font-weight: bold;
font-family: verdana, arial; /* Font */
color: #000; /* Text Color */


/* Do not edit this area */
position: absolute;top: 0;left: 0;z-index: 3000;cursor: default;}
#outerCircleText div {position: relative;}
#outerCircleText div div {position: absolute;top: 0;left: 0;text-align: center;}
</style>
<script type='text/javascript'>
//<![CDATA[
/* Circling text trail- Tim Tilton
Website: http://www.tempermedia.com/
Visit: http://www.dynamicdrive.com/ for Original Source and tons of scripts
Modified Here for more flexibility and modern browser support
Modifications as first seen in http://www.dynamicdrive.com/forums/
username:jscheuer1 - This notice must remain for legal use
*/


;(function(){


// Message
var msg = "Welcome to Shivam Paints LTD.";


// Font size
var size = 22;


// Determines whether circular or oval, 1 for circular and 2 for oval
var circleY = 0.75; var circleX = 2;


// Space between each letter
var letter_spacing = 5;


// Diameter of the circle
var diameter = 10;


// Rotation speed
var rotation = 0.3;


// Reaction Speed
var speed = 0.2;


////////////////////// Do not edit anything else //////////////////////


if (!window.addEventListener && !window.attachEvent || !document.createElement) return;


msg = msg.split('');
var n = msg.length - 1, a = Math.round(size * diameter * 0.208333), currStep = 20,
ymouse = a * circleY + 20, xmouse = a * circleX + 20, y = [], x = [], Y = [], X = [],
o = document.createElement('div'), oi = document.createElement('div'),
b = document.compatMode && document.compatMode != "BackCompat"? document.documentElement : document.body,


mouse = function(e){
e = e || window.event;
ymouse = !isNaN(e.pageY)? e.pageY : e.clientY; // y-position
xmouse = !isNaN(e.pageX)? e.pageX : e.clientX; // x-position
},


makecircle = function(){ // rotation/positioning
if(init.nopy){
o.style.top = (b || document.body).scrollTop + 'px';
o.style.left = (b || document.body).scrollLeft + 'px';
};
currStep -= rotation;
for (var d, i = n; i > -1; --i){ // makes the circle
d = document.getElementById('iemsg' + i).style;
d.top = Math.round(y[i] + a * Math.sin((currStep + i) / letter_spacing) * circleY - 15) + 'px';
d.left = Math.round(x[i] + a * Math.cos((currStep + i) / letter_spacing) * circleX) + 'px';
};
},


drag = function(){ // makes the resistance
y[0] = Y[0] += (ymouse - Y[0]) * speed;
x[0] = X[0] += (xmouse - 20 - X[0]) * speed;
for (var i = n; i > 0; --i){
y[i] = Y[i] += (y[i-1] - Y[i]) * speed;
x[i] = X[i] += (x[i-1] - X[i]) * speed;
};
makecircle();
},


init = function(){ // appends message divs, & sets initial values for positioning arrays
if(!isNaN(window.pageYOffset)){
ymouse += window.pageYOffset;
xmouse += window.pageXOffset;
} else init.nopy = true;
for (var d, i = n; i > -1; --i){
d = document.createElement('div'); d.id = 'iemsg' + i;
d.style.height = d.style.width = a + 'px';
d.appendChild(document.createTextNode(msg[i]));
oi.appendChild(d); y[i] = x[i] = Y[i] = X[i] = 0;
};
o.appendChild(oi); document.body.appendChild(o);
setInterval(drag, 25);
},


ascroll = function(){
ymouse += window.pageYOffset;
xmouse += window.pageXOffset;
window.removeEventListener('scroll', ascroll, false);
};


o.id = 'outerCircleText'; o.style.fontSize = size + 'px';


if (window.addEventListener){
window.addEventListener('load', init, false);
document.addEventListener('mouseover', mouse, false);
document.addEventListener('mousemove', mouse, false);
if (/Apple/.test(navigator.vendor))
window.addEventListener('scroll', ascroll, false);
}
else if (window.attachEvent){
window.attachEvent('onload', init);
document.attachEvent('onmousemove', mouse);
};


})();
//]]>
</script>
    <title>Shivam Paints LTD|Members area</title>
    <link rel="stylesheet" media="screen" type="text/css" href="style.css" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <style type="text/css">
  body,td,th {
    font-family: Arial, "Lucida Grande", Verdana, sans-serif;
}
a:visited {
    color: #606;
}
a:active {
    color: #CF0;
}
  </style>
  <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
  <script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
  <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
  <link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
  </head>

<body>
    <div id="page">
    <div id="header">
      <div id="nav">
        <div id="nav-menu-left"></div>
        <div id="nav-menu">
          <!-- start of navigation -->
          <ul>
            <li><a id ="selected" a href="indexma.php">Home</a></li>
            <li><a href="profile.php">Profile</a></li>
            <li><a href="productsma.php">Products</a></li>
            <li></li>
            <li></li>
          </ul>
          <table width="83" border="0">
            <tr>
              <td width="73"><ul>
                <li><a href="index.php" style="background-image: none;"></a>
                  <form id="form1" name="form1" method="post" action="logout.php">
                    <a href="logout.php" style="background-image: none;">Logout</a>
                  </form>
                </li>
              </ul></td>
            </tr>
          </table>
          <!-- end navigation -->
        </div>
        <div id="nav-menu-right"></div>
      </div>
    </div>
<div class="clearfloats"></div>
      <div id="header2">
        <!-- the large header slogan which is over top of the grass image can either be changed, or removed below -->
        <div id="header2-slogan1">
          <p>Creative, Affordable and Colourful</p>
          <p>&nbsp;</p>
        </div>
        <div id="header2-slogan2">
          <p>Welcome to the world of colors</p></div>
        <!-- end header slogan -->
</div>

  <div id="content">
    <div align="center">
      <table width="200" border="0">
        <tr>
          <th scope="col">    <div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    pageLanguage: 'en'
  }, 'google_translate_element');
}
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>&nbsp;</th>
        </tr>
  </table>


    </div>
    <h1 align="left">
<?php
session_start();
$Username = $_SESSION['Username'];
?>
<?php
echo "you logged in as ".$Username;
?>
    </h1>
<h1 align="left">Members Area </h1>
    <p align="left">Welcome to our members area this is where special offers will be posted and our clients can comment about Shivam Paints and our products.</p>
    <p align="right"><img src="images/special_offer.jpg" alt="" width="291" height="169" /></p>
    <p align="center">There are no special offers currently. Keep visiting the members area to see any new update.</p>
    <p align="center">&nbsp;</p>
    <h4 align="left">You can drop your comments below</h4>
    <form id="form3" name="form3" method="post" action="comments.php">
<p><span id="sprytextfield1">
        <label for="Name2">Name</label>
        <br />
        <input type="text" name="Name" id="Name2" />
      <span class="textfieldRequiredMsg">A value is required.</span></span> </p>
      <p><span id="sprytextarea1">
        <label for="Comments">Comments<br />
      </label>
        <textarea name="Comments" id="Comments" cols="45" rows="5"></textarea>
      <span class="textareaRequiredMsg">A value is required.</span></span></p>
      <p>
        <input type="submit" name="Comment" id="Comment" value="Comment" />
      </p>
       <?php 
 // Connects to your Database 
 mysql_connect("localhost", "root", "") or die(mysql_error()); 
 mysql_select_db("spl") or die(mysql_error()); 
 echo "Below are comments made by you and others:";
 $data = mysql_query("SELECT * FROM comments") 
 or die(mysql_error()); 
 Print "<table border cellpadding=3>"; 
 while($info = mysql_fetch_array( $data )) 
 { 
 Print "<tr>"; 
 Print "<th>Name:</th> <td>".$info['Name'] . "</td> "; 
 Print "<th>Comments:</th> <td>".$info['Comments'] . " </td></tr>"; 
 } 
 Print "</table>"; 
 $data = mysql_query("SELECT * FROM comments") 
 or die(mysql_error()); 
  ?>
    </form>
    <p align="left">&nbsp;</p>
    <p align="left">&nbsp;</p>
    <p align="left"></p>
    <p align="left"></p>
  </div>
<div>
  <div id="footer">

    <p align="center">Website &copy; Copyright Shivam Paints LTD.</p> <p align="right">&nbsp;</p>
  </div>
</div>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1");
</script>
</body>
</html>

And the login.php is:-

    <?php
    $host="localhost"; 
    $username="root";
    $password=""; 
    $db_name="spl"; 
    $tbl_name="registration"; 

    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");

    $Username=$_POST['Username'];
    $Password = MD5($_POST['Password']);


    $Username = stripslashes($Username);
    $Password = stripslashes($Password);
    $Username = mysql_real_escape_string($Username);
    $Password = mysql_real_escape_string($Password);

    $sql="SELECT * FROM $tbl_name WHERE Username='$Username' and Password='$Password'";

    $result=mysql_query($sql);


    $count=mysql_num_rows($result);

    if($count==1)
    {
      session_register('Username');
      header("location:indexma.php"); // put your home page neme here
    }
    else
    echo "login fail";
    ?>

the error/warning is as follows:-

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\Shivam1\indexma.php:148) in C:\wamp\www\Shivam1\indexma.php on line 227

any help will be apriciated.

Recommended Answers

All 2 Replies

session_start() needs to be at the top of your script, before anything is outputted.

thanks pritaeas worked flowlessley

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.