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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.