Location: PHPKode > projects > PHP Choral Music Library > choralmusiclib-1.5/index.php
<?php

include ("config.php");
include ("librarylib.php");

session_start();

import_request_variables("gP","");

require_once("sessioncheck.php");

html_begin($choralcfg_sitename, $choralcfg_sitename, $choralcfg_cssfile);

if( isset($login_passwd) ) {
   $sql = "SELECT * FROM user WHERE
           username = '$login_user' AND
           password = '$login_passwd'";

   $result = mysql_query( $sql, $_SESSION["link"] )
      or die("$choral_cannotlookupuserindb\n");

   $num = mysql_numrows( $result );

   if ( $num != 0) {
      $row = mysql_fetch_object($result);
      $timestamp = date("YmdHis");
      if ($DEBUG) print "timestamp = $timestamp\n\n";

      $user_id = $row->user_id;
      $username = $login_user;
      $last_name = $row->last_name;
      $first_name = $row->first_name;
      $this_name = $first_name." ".$last_name;
      $permission = $row->permission;

      $sql = "select thislogin from user where user_id=$user_id";
      $result = mysql_query( $sql )
         or die("Unable to select login time for user in database.\n");
      $row2 = mysql_fetch_object($result);
      $lastlogin = $row2 -> thislogin;
      $sql = "update user set lastlogin='$lastlogin' where user_id=$user_id";
      $result = mysql_query( $sql )
         or die("$choral_unabletosetlastlogintime\n");
      $sql = "update user set thislogin='$timestamp' where user_id=$user_id";
      $result = mysql_query( $sql )
         or die("$choral_unabletosetcurrentlogintime\n");

      $message = "<p>$choral_succesfulloggedin $this_name.</p>\n";
     
      // Succesfull login, so setting Session data
      $_SESSION["this_name"] = $this_name;
      $_SESSION["user_id"] = $user_id;
      $_SESSION["username"] = $username;
      $_SESSION["permission"] = $permission;
   } else {
      $message = "<p>$choral_unabletofindusername</p>\n";
   }
}

//print "$this_name $username $permission $login_user $login_passwd";

print "<TABLE border=\"0\" cellpadding=\"0\" ".
      "cellspacing=\"5\">\n";
print "<TR><TD valign=\"top\" nowrap>\n";
include("links.phtml");
print "</TD>\n";
print "<TD>";
print "$message";
//print session_id();
//print "\n $user $passwd";
include("main.phtml");
library_footer();
print "</TD></TABLE>";
html_end();

?>
Return current item: PHP Choral Music Library