New to php: BIG QUESTION SAVE ME!!!!
Posted: Fri Sep 20, 2002 4:25 am
I'm new to php (i just started learning yesterday!!!) and i want to make a login page. The user logins to an Oracle 9i server. the problem is that i want to personalize the pages for each user. For example i want to execute a specific sql statement for the specific user. my code is the following
and the OracleCon.inc file is the following:
the problem is when the user logins i get the following warnings:
Warning: Cannot send session cookie - headers already sent by (output started at c:\program files\apache group\apache\htdocs\php\login2.php:10) in c:\program files\apache group\apache\htdocs\php\login2.php on line 13
Warning: Cannot send session cache limiter - headers already sent (output started at c:\program files\apache group\apache\htdocs\php\login2.php:10) in c:\program files\apache group\apache\htdocs\php\login2.php on line 13
session started
Warning: Cannot add header information - headers already sent by (output started at c:\program files\apache group\apache\htdocs\php\login2.php:10) in c:\program files\apache group\apache\htdocs\php\login2.php on line 18
What is wrong with it?
Code: Select all
<?php
include "OracleCon.inc";
$username = $HTTP_POST_VARSї'username'];
$password =$HTTP_POST_VARSї'password'];
if (isset($username) && isset($password)) {
$oracle = new OracleCon($username, $password, "DEV_ORION");
if ($oracle->ConnectToDB()){
if (session_start()){
echo "session started<br>";
}
$connection=array(serialize($oracle));
session_register("connection");
header("Location: search.php");
exit;
}else{
header("Location: fail.php");
exit;
}
}
?>
<html>
<head>
<title>Oracle Login - Start Page</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<h2>Oracle Login - Start Page</h2>
<form action="login2.php" method="POST">
Username: <input name="username" type="text" /><br />
Password: <input name="password" type="password" /><br />
<input type="submit" value="Log in" />
</form>
</body>
</html>Code: Select all
<?php
class OracleCon{
var $username;
var $password;
var $alias;
var $conn;
var $stmt;
var $sql_statement;
function OracleCon($username, $password, $alias){
$this->username=$username;
$this->password=$password;
$this->alias=$alias;
}
function ConnectToDB(){
$this->conn = OCIPLogon($this->username, $this->password, $this->alias);
if (!OCIError()){
return true;
}else{
return false;
}
}
function DisconnectFromDB(){
OCILogOff($this->conn);
}
function CreateStatement(){
$this->stmt="select DEMO_ID, DSC from patsavouris.demo where user_name='".$this->username."'";
}
function ExecuteStatement(){
$this->sql_statement = OCIParse($this->conn, $this->stmt, 1);
OCIExecute($this->sql_statement);
}
function ShowResults(){
echo "<TABLE BORDER=1>";
echo "<TR><TH>ID</TH><TH>DSC</TH>";
while (OCIFetch($this->sql_statement)){
echo "<TR>";
$num_cols = OCINumCols($this->sql_statement);
for ($i = 1; $i <= $num_cols; $i++) {
$column_value = OCIResult($this->sql_statement,$i);
echo "<TD>$column_value</TD>";
}
echo "</TR>";
}
echo "</TABLE>";
}
}
?>Warning: Cannot send session cookie - headers already sent by (output started at c:\program files\apache group\apache\htdocs\php\login2.php:10) in c:\program files\apache group\apache\htdocs\php\login2.php on line 13
Warning: Cannot send session cache limiter - headers already sent (output started at c:\program files\apache group\apache\htdocs\php\login2.php:10) in c:\program files\apache group\apache\htdocs\php\login2.php on line 13
session started
Warning: Cannot add header information - headers already sent by (output started at c:\program files\apache group\apache\htdocs\php\login2.php:10) in c:\program files\apache group\apache\htdocs\php\login2.php on line 18
What is wrong with it?