tet3828 Posted November 9, 2006 Share Posted November 9, 2006 I put a auto login snippit at the begging of my script. some variables are passed from a flash projector to this page to set the user name and password. If I login with the correct username password stored in my database:[code]Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/content/t/e/t/tetunity/html/shell/data/index.php:7) in /home/content/t/e/t/tetunity/html/shell/data/index.php on line 21Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/t/e/t/tetunity/html/shell/data/index.php:7) in /home/content/t/e/t/tetunity/html/shell/data/index.php on line 21Warning: mysql_result(): userName not found in MySQL result index 2 in /home/content/t/e/t/tetunity/html/shell/data/index.php on line 36You're logged in.[/code]when I login with an incorrect password username....I included the html headers incase something up there is conflicting with my session login script[code]Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/content/t/e/t/tetunity/html/shell/data/index.php:7) in /home/content/t/e/t/tetunity/html/shell/data/index.php on line 21Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/t/e/t/tetunity/html/shell/data/index.php:7) in /home/content/t/e/t/tetunity/html/shell/data/index.php on line 21[/code][b]Please help if anyone has any ideas on how I could solve these errors and make this script properly. ???[/b]here is the script I am using.[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><style type="text/css"><!--a:link { color: #000000;}a:visited { color: #000000;}--></style></head><body><center><?phpsession_start();session.cookie_lifetime(120); \\\ NOT REALLY SURE WHERE TO PUT THIS SESSION TIMER!!!if (! isset($_SESSION['name'])) { if(isset($_GET['userName'])) { $userName = $_GET['userName']; \\\ I know I should use $_POST but macromedia flash projectors don't allow it. $userPass = $_GET['userPass']; mysql_connect("mysql213.secureserver.net","*****","*****"); mysql_select_db("*********"); $query = "SELECT nameFirst FROM users WHERE userName='$userName' AND userPass='$userPass'"; $result = mysql_query($query); if (mysql_numrows($result) == 1) { $_SESSION['name'] = mysql_result($result,0,"nameFirst"); $_SESSION['username'] = mysql_result($result,0,"userName"); echo "You're logged in."; } } else { include "verify.php"; }} else { $userName = $_SESSION['name']; echo "Welcome back $Username";}[/code] Quote Link to comment Share on other sites More sharing options...
trq Posted November 9, 2006 Share Posted November 9, 2006 session_start() needs to be called before ANY output to the broswer. That meens ALL html. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.