1

So I have created this attendance system where you can add photos of each person and the person can click their photo and it will let you know that they have checked in. However I have a little issue. When you click on a photo, it says every person added to the system has been checked in. Can anyone give me suggestions on what I can do to make each picture become a seperate button and also when you click on that picture the name associated with that picture will be the only one that is checked in.

I know I am using a text file for practice purposes but when I figure out how to make it work correctly I plan on using the MySQL database with php for storing the check in/ check out data.

Also when you enter the page it automatically checks everyone in.

Here is the link. It's a full system. You have to register, then login, then click the check in button at the top left to see the Check in page.

https://bluebrazentech.com/login/martinenrichment/register.php

access code: mea2018

Here is the part my code below that shows how I wrote the check in functionality. Thank you in advance.

 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>
  • 3
    "I plan on using the MySQL database with php" Honestly, scrap what you have and go straight to this. If you know that this is how it's going to be, there's no point building it a different, less appropriate way first. – Patrick Q Aug 22 '18 at 18:38
  • To Patrick Q..... What would you propose I do to make the button check in each individual without using the fp/fopen/fgets/timetracker.txt way? – Davmarius Ndikumasabo Aug 22 '18 at 20:07
  • I would like to keep my while statement that echos the div and the form – Davmarius Ndikumasabo Aug 22 '18 at 20:10
  • I propose that you do it they way you already say you "plan" on doing it. Store the users and their status in a db, and then look up the status by user ID. – Patrick Q Aug 22 '18 at 20:14
  • my users are stored in the database... The only thing that is not stored is the part that says if they are checked in o checked out.... I'm trying to find a way to make the pictures separate once they upload on the web page... – Davmarius Ndikumasabo Aug 22 '18 at 20:20
  • the pictures seem to stay connected to one another in the function that I have created and I don't know how to make them act as separate buttons in my while statement – Davmarius Ndikumasabo Aug 22 '18 at 20:22
  • it would really help if someone knew how to help me make the pictures that I turned into buttons separate into individual buttons once added to the web page. – Davmarius Ndikumasabo Aug 22 '18 at 20:24
  • Thank you Patrick Q for your suggestioins. I appreciate your willingness to help. I did add the status in the db after I was able to seperate the image button into seperate id's and it work exactly the way I needed it to work. – Davmarius Ndikumasabo Aug 26 '18 at 03:37

1 Answers1

0

I found out how to do what I needed thanks to Doug Neiner's response/answer in the link below:

Give ID/Class to generated images

His response showed me how to give uploaded images seperate id's. After doing that I could seperate each image uploaded eventhough I only use one input button for all images.

Thank you Doug!!!