所以我创建了这个考勤系统,您可以在其中添加每个人的照片,然后该人可以单击他们的照片,它会让您知道他们已经签到。但是我有一个小问题。当您单击一张照片时,它表示已添加到系统中的每个人都已签入。任何人都可以给我建议,告诉我我可以做些什么来使每张照片成为一个单独的按钮,以及当您单击该图片时,与相关联的名称那张照片将是唯一一张被签入的照片。
我知道我正在使用文本文件进行练习,但是当我弄清楚如何使其正常工作时,我计划使用 MySQL 数据库和 php 来存储签入/签出数据。
此外,当您进入页面时,它会自动检查每个人。
链接在这里。这是一个完整的系统。您必须注册,然后登录,然后单击左上角的签入按钮以查看签入页面。
https://bluebrazentech.com/login/martinenrichment/register.php
访问代码:mea2018
下面是我的代码部分,它显示了我是如何编写签入功能的。先感谢您。
while ($row = mysqli_fetch_array($result)) {
echo "<div id='img_div'>";
echo "<form method = 'post' action=''>";
// this is how I make each photo into a button
echo "<input type ='image' id = 'myImg' width = '80%' alt = 'Submit' src='upload/".$row['image']."' />";
echo "<p>".$row['first_name']."</p>";
echo "<p>".$row['last_name']."</p>";
echo "</form>";
echo "</div>";
// when they click the photo this will give them a timestamp with their name but multiple names are coming up instead of the name connected to the photo.
date_default_timezone_set("America/Chicago");
$fp = fopen("timetracker.txt", "a");
$timestamp = date("l jS \of F Y h:i:s A");
$savestring = $timestamp . " $variable1 " . $row['first_name'] . " $variable1 " . "clocked in" . "\n";
fwrite($fp, $savestring);
fclose($fp);
$file = fopen("timetracker.txt", "r");
}
?>
<pre>
<?php
while ($line = fgets($file)){
echo $line;
}
?>
</pre>