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