Lucky-8
March 19th, 2008, 12:16 AM
hello,
My aim is to acheive user authentication using session. on my local server (wamp) on my system it seems to work fine but when i upload the files to my host server i get this "headers sent" warning and eventually the session does not get created and i can further navigate the website.
below is the code
<?php include "mysql.php" ?>
<?php
ob_start();
// Define $myusername and $mypassword
$myusername=$_POST['username'];
$mypassword=$_POST['password'];
$obj=new db();
//$obj-> connect("root","","drycleaning");
$obj->connect("scp_training","vTech123","scp_training");
//$obj->connect("drycleaning","vTech123","drycleaning");
$query="SELECT * FROM user_info WHERE email='$myusername' and password='$mypassword'";
$result=$obj->query($query);
$count = $obj->numrow($result);
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION['myusername']=$myusername;
include("home2.php");
}
else {
include("index2.php");
}
ob_end_flush();
?>
And at the begining of everypage i have the following code embedded.
<?php
session_start();
if(!$_SESSION['myusername'])
{
header("location:index.php");
}
?>
My aim is to acheive user authentication using session. on my local server (wamp) on my system it seems to work fine but when i upload the files to my host server i get this "headers sent" warning and eventually the session does not get created and i can further navigate the website.
below is the code
<?php include "mysql.php" ?>
<?php
ob_start();
// Define $myusername and $mypassword
$myusername=$_POST['username'];
$mypassword=$_POST['password'];
$obj=new db();
//$obj-> connect("root","","drycleaning");
$obj->connect("scp_training","vTech123","scp_training");
//$obj->connect("drycleaning","vTech123","drycleaning");
$query="SELECT * FROM user_info WHERE email='$myusername' and password='$mypassword'";
$result=$obj->query($query);
$count = $obj->numrow($result);
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION['myusername']=$myusername;
include("home2.php");
}
else {
include("index2.php");
}
ob_end_flush();
?>
And at the begining of everypage i have the following code embedded.
<?php
session_start();
if(!$_SESSION['myusername'])
{
header("location:index.php");
}
?>