Jump to content

Login Script Problem...


puritystandsout

Recommended Posts

Please could you help?  Here is my script:

[code]
<?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';
}
?>
[/code]
----------------------------------------------

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
Link to comment
https://forums.phpfreaks.com/topic/14568-login-script-problem/
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.