View Single Post
Old Feb 20th, 2008, 12:21 AM   #12
MrMan9879
Programmer
 
MrMan9879's Avatar
 
Join Date: Sep 2005
Location: Nanaimo, BC, Canada
Posts: 95
Rep Power: 0 MrMan9879 is an unknown quantity at this point
Send a message via MSN to MrMan9879
Re: Sessions Problem

For some reason I can't edit... so sorry for the double post...

I just read Ooble's post about wanting to see the code before this segment.. so i will show you the code.

The login script is actually in a separate php file that I include into the index file.

if (!empty($_POST['user']) && !empty($_POST['pass'])) {
	//if the user has sent a new user name and password, assign them to new variables
	$new_user = $_POST['user'];
	$new_password = sha1($_POST['pass']);
	
	$sqlCon = mysql_connect($db_host, $db_user, $db_password);
	//connect to the database
	$myDB = mysql_select_db($db_name, $sqlCon);
	//select the appropriate database
	$sql = 'SELECT * FROM `users`';
	//setup the sql
	$query = mysql_query($sql, $sqlCon);
	//send the query and then check for errors
	if (!$query) {
		die('Error: ' . mysql_error());
	}

I have another included file at the top of my index file that starts the session too:

<?php
session_start();

$_SESSION['user_name'] = $_COOKIE['user_name'];
$_SESSION['password'] = $_COOKIE['password'];

if (!empty($_SESSION['user_name']) && !empty($_SESSION['password'])) {
	$user=$_SESSION['user_name'];
	$password=$_SESSION['password'];
}

?>

I don't really think any of this is messing up making the cookies, but I could be wrong.

I'm using this script on a subdomain (bcssa.andrewsmythe.net)... this wouldn't be messing things up would it?
MrMan9879 is offline   Reply With Quote