Jump to content

Sessions auto login script errors


tet3828

Recommended Posts

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 21

Warning: 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

Warning: mysql_result(): userName not found in MySQL result index 2 in /home/content/t/e/t/tetunity/html/shell/data/index.php on line 36
You'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 21

Warning: 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>
<?php
session_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]
Link to comment
https://forums.phpfreaks.com/topic/26706-sessions-auto-login-script-errors/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.