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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Members Area 1

Status
Not open for further replies.

TrueJoker

Technical User
Jun 14, 2006
115
GB
The Members Area i have created was working fine, and then suddenly i get this warning/error when i test the new member sign up script

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/httpd/vhosts/impa.net/httpdocs/new_member.php:6) in /home/httpd/vhosts/impa.net/httpdocs/new_member.php on line 223

now the php code that this is refering to is as follows

Code:
Line in code.
\/
218. <?php
219. 	session_start();
220. 	 
221.	if (@$_SESSION['auth'] != "yes")
222.	{
223.		header("Location: login.php");
224.		exit();
225.	}
226.	include("doc.inc");
227.	$connection = mysql_connect($host,$user,$password)
228.	or die ("Couldn't connect to the server.");
229.	$db = mysql_select_db($database, $connection)
230.		or die ("Couldn't connect to database.");
231.	$sql = "SELECT contact,company FROM Member
232.		WHERE loginName='{$_SESSION['logname']}'";
233.	$result = mysql_query($sql)
234.			or die("Couldn't execute query 1.");
235.	$row = mysql_fetch_array($result,MYSQL_ASSOC);
236.	extract($row);
237.	echo	"<html>
238	 <head><title>New Member Welcome</title></head>
239.			 <body>
240.		<h2 align='center' style='margin-top: .9in'>
241.		 Welcome $contact at $company</h2>\n";
242. ?>

This was working fine before! i ahvent changed anything but ahve no idea why this error appears, it still adds the new members details to the database :S
 
you have some output createt at line 6 in that file. look for a blank line outside of the php tags or something similar. if in doubt post the first 10 lines from that file.
 
Here are the first 10 lines of this document!

Code:
1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
2. <html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"><!--[/URL] InstanceBegin template="/Templates/membership.dwt" codeOutsideHTMLIsLocked="false" -->
3. <head>
4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
5. <!-- InstanceBeginEditable name="doctitle" -->
6. <title>Welcome to IMPA</title>
7. <!-- InstanceEndEditable -->
8. <link href="text.css" rel="stylesheet" type="text/css" />
9. <style type="text/css">
10. <!--

This is really strange because it was working perfectly fine some time ago!
 
well - there's your problem. you are outputting html conten before you start the php. this will never have worked - i promise. you are just seeing a different behaviour as previously the auth element of $_SESSION has been set to yes properly so the header redirection has not been triggered.

i don't tend to use redirects for this reason. i keep all input and output going to and from the same page, and control the user experience using included files. this is called a variety of names: despatch method is the most common. there is a good article on it at phpsec.org. it leads to clean code, clean file trees and good security.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top