Jump to content


Photo

Login Script Problem...


  • Please log in to reply
2 replies to this topic

#1 puritystandsout

puritystandsout
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 14 July 2006 - 08:55 AM

Please could you help?  Here is my script:

<?php
// start the session
session_start();

$errorMessage = '';
if ( (isset($_POST['username'])) && (isset($_POST['password'])) ) {
   include '../db/config.php';
   include '../db/opendb.php';

   $username = $_POST['username'];
   $password = $_POST['password'];
   $password_hashed = md5($password);
   

		   // check if the user id and password combination exist in database
		   $sql = "SELECT *
				   FROM accounts
				   WHERE username = '$username'
				   AND password = '$password_hashed' ";
		
		   $result = mysql_query($sql)
					 or die('Query failed. ' . mysql_error());
		
		   if (mysql_num_rows($result) == 1) {
			  // the user id and password match,
			  // set the session
			  	while ($member_details_array = mysql_fetch_assoc($result)) {
					
					$member_id = $member_details_array['member_id'];
				
					$_SESSION[$member_id] = true;
					}
			  		
					
							
			  // after login we move to the main page
			  header("Location: main.php");
			  exit;
		   } else {
			  $errorMessage = 'Sorry, wrong username and password combination';
		   }

		
		   include '../db/closedb.php';
}
?>
----------------------------------------------

It seems to do all the db stuff ok, logs the user in but I get this error:

Cannot modify header information - headers already sent by ...

Many Thanks in advance for your help.

Regards and Jesus Christ's blessings,

Chris Cundill

#2 puritystandsout

puritystandsout
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 14 July 2006 - 09:07 AM

Fixed it sorry to bother you.

For the benefit of the community it was blank lines after my closing ?> and the beginning of my html!

Thats all!

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 14 July 2006 - 12:55 PM

sometimes it's better to get more sessions set ok like.

$_SESSION['name'];
ect
ect

then in the future you can use them ok.

good luck.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users