Location: PHPKode > projects > phpHamLog > phphamlog/phphamlog/login.php
<?php
/***************************************************************************
 phpHamLog

 $Id: login.php,v 1.2 2006/04/29 02:53:53 kc9aop Exp $

 Copyright (c) 2005 KC9AOP

 ***************************************************************************/

session_start();
include "auth.php";
#include "configure.php";

$loggedin = FALSE;

switch ($program) {
	case "FIELDDAY":
	/* if user does not have a callsign, use the club's callsign for field day logging */
	  	if (strlen($password) == 0 ) 
	  		$password = $mastercall;
	  	$password = strtoupper($password);
	  	$logcallid = $password;
	  	$storage = 'Y';
		$sql = "SELECT logcallid, storage FROM cookies WHERE logcallid = '$password' ";
		$result = mysql_query ($sql, $db)
  			or error_die ("login.php: Could not get 'cookies' data from database. #1");
		$myrow = mysql_fetch_array($result);
		if (strcmp($myrow[logcallid],$password) == 0 ) {
		/* user has already logged in at least once, update cookie */
			$sql = "UPDATE cookies SET storage = '$storage' WHERE logcallid = '$password' ";
			$result = mysql_query ($sql, $db)
  				or error_die ("login.php: Could not update 'cookies' data in database. #2");
  		} else {
  		/* user has never logged into program, enter the user into the cookies table */
  		/* BUT only if user is not the default callsign */
  			if (strcmp($mastercall,$password) != 0) {
				$sql = "INSERT INTO cookies (logcallid, storage ) VALUES ('$logcallid', '$storage' )";
				$result = mysql_query ($sql, $db)
  					or error_die ("login.php: Could not add 'cookies' data to database. #2");
  			}
  		}
     		$loggedin = TRUE;
     		session_register("logcallid");  /* Let us set the logon callsign */
     		break;
	default:
		if (strcmp($password, $mylogpass) == 0) {
			$storage = 'Y';
			$sql = "UPDATE cookies SET storage = '$storage' WHERE storeid = '1' ";
			$result = mysql_query ($sql, $db)
  				or error_die ("Could not update 'cookies' data in database");
     			$loggedin = TRUE;
		}
}

?>
<html>
<head>
<?php
  //echo "<meta http-equiv=\"Refresh\" content=\"3;url=$myphphamlogroot/logentry.php?user=owner\">"
 ?>
</head>
<body>
<?php
   if ($loggedin == TRUE) {
     //echo "You are now logged in.<br><br>\n\n";
     header("Location: logentry.php?user=owner");
   }
   else
   {
     //echo "Are you sure you did that right?<br><br>\n\n";
     header("Location: index.php?o=error");
   }


?>
</body>
</html>
Return current item: phpHamLog