you know im not that good im still learning and the first thing im doing now is users management system.
it's really simple and easy all im doing is an
constants.php{witch's hold my database details}
connection.php{witch's where i start my connection and selceting my database name}
and i started my session at the top of the connection.php page like this...
PHP Code:
<?php
session_start();
require("constants.php");
//the database connection
$connection = mysql_connect(DB_SERVER,DB_USER);
if(!connection){
die("Database connection failed: " . mysql_error());
}
//select database
$db_select = mysql_select_db(DB_NAME, $connection);
if(!$db_select){
die("database selection failed:" . mysql_error());
}
?>
the session_start(); function at the top when i type it i got this error
Code:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\xampp\htdocs\login script\index.php:1) in D:\xampp\htdocs\login script\includes\connection.php on line 2
...
i have tow pages the first one is index.php that where people will login here an image for examble
and an register page and everything okay with the register page
here is the code of the index.php
PHP Code:
<?php require_once("includes/connection.php"); ?>
<html>
<head>
<title>User Login</title>
</head>
<style>
body{background:#dbdbdb; margin:0; padding:0; font:'Verdana', Geneva, sans-serif;}
</style>
<link href="stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />
<body>
<div id="box_outter">
<div id="box_bg">
<div class="header">
<img src="images/logo.gif" alt="Logo" class="logo">
<img src="images/bigman.jpg" alt="bigman" class="bigman">
</div>
<?php
if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['username']))
{
?>
<p>Welcome back<?=$_SESSION['username']?>.</p>
<ul>
<li><a href="logout.php">Logout.</a></li>
</ul>
<?php
}
elseif(!empty($_POST['username']) && !empty($_POST['password']))
{
$get_username = mysql_real_escape_string($_POST['username']);
$get_password = md5(mysql_real_escape_string($_POST['password']));
$checklogin = mysql_query("SELECT * FROM users WHERE username = '".$username."' AND password = '".$password."'");
if(mysql_num_rows($checklogin) == 1)
{
$row = mysql_fetch_array($checklogin);
$_SESSION['get_username'] = $username;
$_SESSION['LoggedIn'] = 1;
echo "<p>you now logged in successfully</p>";
echo "<meta http-equiv='refresh' content='=3;index.php' />";
}
else
{
echo "<p>this user dose not exist</p>";
}
}
else
{
?>
<div class="body">
<div class="login_box">
<h1 class="li-h"></h1>
<form action="index.php" method="post" class="login_box_out">
<input type="text" name="get_username" class="user_form" value="Username"
onfocus="if(this.value=='Username'){this.value=''};" onBlur="if(this.value==''){this.value='Username'};">
<input type="password" name="get_password" class="pass_form" value="password"
onfocus="if(this.value=='password'){this.value=''};" onBlur="if(this.value==''){this.value='password'};">
<input type="submit" name="login" class="login_btn" value=" ">
</form>
<a href="register.php" class="reg-link">Register</a>
</div>
</div>
<?php } ?>
</div>
</div>
</body>
</html>
<?php
mysql_close($connection);
?>
and as we can see above of the code we required once the connection.php and the example for the connection at the top of the topic
notice that when i get rid of the session_start(); function everything okay and no erorr will come to me
so please people anyhelp with that cuz i really want to know the solve of this problem and i tired of searcing in google