Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with SESSION

Status
Not open for further replies.

tekpr00

IS-IT--Management
Jan 22, 2008
186
CA
Hello All,

Please can somone help with my I am getting:

Fatal error: Call to undefined function strtlower() in /home/tayo/public_html/session.php on line 44

I have indicated my line 44 with a comment. Thanks

Here is my code

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
 <head>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  
  <title> session form </title>
  <style type="text/css" media="screen">.number {font-weight: bold;} </style>
 </head>
 <body>

 <form action="session.php" method="post">

 <p> Username <input type="text"
 name="username" size="20" /></p>

 <p> Password <input type="text"
 name="password" size="20" /></p>
 
  <p> Please log in <input type="submit"
 name="submit" value= "log In" /></p>

<input type="hidden" name="submitted"
value="true" />
<h1> LOG IN FORM </h1>
</form>
<?php 
/* This script takes values from above and use them in the function below. */

//Set the page title
define('TITLE', 'Login');
//recquire('[URL unfurl="true"]http://student.codelesson.com/~tayo/index.php')[/URL]
require('templates/header.html');

//into text

//Print'<h1> Login form</h>
//<p> Please login use in </p>';

//Check if the form has been submitted
if(isset ($_POST['submitted'])){
//handle form
	if((!empty($_POST['username'])) && (!empty ($_POST['password']))){
		if((strtlower($_POST['username'])=='james') && ($_POST['password']=='mailman')){///this is line 44
		//Do something here
		sesstion_start();
		$_SESSION['username'] =$_POST['username'];
		$_SESSION['loggedin']=time();
		
		///tell the user to the web page
		ob_end_clean();
		heaader('[URL unfurl="true"]http://local.codelesson.com/~james/index.php');[/URL]
		exit();
		}
		else 
		{
		print'<p> Username and Password not mactched the record</p>';
		}
	}
	else {
	Print'<p> Please enter Username and Password </p>';
	}
}else {//Display form
print '<form action="session.php" method="post">
<input type="hidden" name="submitted" value="true" />
</form>';
}
require('templates/footer.html');
?>
</body>
</html>
 
After correcting the name of the funcion, I am still getting the errors below. Please I will appreciate it if specific suggestion is given.

Here are errors.
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/tayo/public_html/session.php:27) in /home/tayo/public_html/session.php on line 46

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/tayo/public_html/session.php:27) in /home/tayo/public_html/session.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at /home/tayo/public_html/session.php:27) in /home/tayo/public_html/session.php on line 52
 
Same basic principle as with the cookies. There can be no output to browser before using sessions.

In short your PHP code that starts the sessions must be placed before any HTML, text, or white space in your file.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Is there any changes in the code that you can suggest for me to make. Sorry being a newbie I am kind of cofused as to exactly where in the code I should make the change.

Your effort will be highly appreciated.
 
Insert this line at the very top of the script
Code:
<?php if (session_id() ==') session_start(); ?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top