Example code for LAMP server (mf-web08s)

with No Comments

The following example script assuming the database "dbname" has a table "dbtable" with fields for storing uid, date, time, and system datetime.

<?php
$db_host="localhost";
$db_user="dbuser";
$db_pwd="dbpassword";
$db_name="dbname";
$db_table="dbtable";

if (!mysql_connect($db_host,$db_user,$db_pwd)) {
  die( "Unable to connect host");
}

if (!mysql_select_db($db_name)) {
  die( "Unable to select database");
}

$now=time();
$st=date('Y-m-d H:i:s',$now);

$cmd=$_GET["cmd"];
$date=$_GET["date"];
$time=$_GET["time"];
$dt=$date . ' ' . $time;
$uid=$_GET["uid"];

echo "<html><body>";
if ($cmd=="CO") {
  $query = "INSERT INTO $db_table VALUES ('$uid','$dt','$st','$cmd')";
  $result=mysql_query($query);
  echo "<AVEA>" // start flag
  echo "CK=$st"; // set clock
  echo "GRNT=01"; // granting access
  echo "</AVEA>"; // end flag
  flush();
}
echo "</body></html>";
?>

 

Leave a Reply

You must be logged in to post a comment.