save fingerprint in database"mysql"

Hello everyone

I really need a help ; i'm working on my final project that's about attendance by fingerprint

I finished my app , php and database in mysql also the hardware working well
but the problem is HOW CAN I SAVE FINGERPRINT IN DB .
I read about base64 to convert image to string or unique id but, I can't get the idea of it
in addition, i don't have an experience to do it can u help me please . The submission after 4 week is too short time . :frowning: :frowning: :sob:

Lamyaa:
I finished my app , php and database in mysql also the hardware working well
but the problem is HOW CAN I SAVE FINGERPRINT IN DB .
I read about base64 to convert image to string or unique id but, I can't get the idea of it
in addition, i don't have an experience to do it can u help me please . The submission after 4 week is too short time . :frowning: :frowning: :sob:

Your time crunch is not our concern.

And this is not a forum about databases.

.

ieee488:
Your time crunch is not our concern.

And this is not a forum about databases.

.

yeah i know
but How to get unique id to save it in database as u know we can't save image as it is, we have to convert it .. i mean How can i do it with fingerprint and arduino

I think about “how can i save fingerprint in the database”

in my code of fingerprint … I ask about ID first then enroll finger so ID will save it with unique fingerprint
So i will save ID in the database .
NOW I face anther issue that’s in sending data in DB arduino send just zeros … i have searched more but i didn’t get anything
I use ethernt shield , php , mysql and Xampp
arduino code

#include <Adafruit_Fingerprint.h>
#include <SPI.h>
#include <Ethernet.h>
#include <SoftwareSerial.h>
byte mac[] = { 0xDE, 0xAD, 0xCE, 0xAF, 0xFE, 0xDD};
IPAddress ip(192,168,1,10); //IP address for your arduino.
char server[] = "192.168.1.5"; //IP address of your computer.
int interrupt=0; //Variable to control the iterations of void loop().
String mod=""; //Variable to be written on the database.
String rcv=""; //Variable in which the server response is recorded.
EthernetClient client;
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

uint8_t id;

void setup()  
{
  Serial.begin(9600);
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  delay(100);
  Serial.println("\n\nAdafruit Fingerprint sensor enrollment");

  // set the data rate for the sensor serial port
  finger.begin(57600);
  Ethernet.begin(mac, ip);
  delay(5000); //Wait for ethernet to connect.
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1) { delay(1); }
  }
}
void httpRequest()
{// Connect to the server (your computer or web page)  
  if (client.connect(server, 80)) {
    client.print("GET /ethernt/data.php?"); // This
    client.print("ID_S"); // This
    client.print(id); // And this is what we did in the testing section above. We are making a GET request just like we would from our browser but now with live data from the sensor
    client.println(" HTTP/1.1"); // Part of the GET request
    client.println("Host: 192.168.1.5"); // IMPORTANT: If you are using XAMPP you will have to find out the IP address of your computer and put it here (it is explained in previous article). If you have a web page, enter its address (ie.Host: "www.yourwebpage.com")
    client.println("Connection: close"); // Part of the GET request telling the server that we are over transmitting the message
    client.println(); // Empty line
    client.println(); // Empty line
    client.stop();    // Closing connection to server

  }

  else {
    // If Arduino can't connect to the server (your computer or web page)
    Serial.println("--> connection failed\n");
  }
}


uint8_t readnumber(void) {
  uint8_t num = 0;
  
  while (num == 0) {
    while (! Serial.available());
    num = Serial.parseInt();
  }
  return num;
}

void loop()                     // run over and over again
{
  
  Serial.println("Ready to enroll a fingerprint!");
  Serial.println("Please type in the ID # (from 1 to 127) you want to save this finger as...");
 id = readnumber();
  if (id == 0) {// ID #0 not allowed, try again!
     return;
  }
  Serial.print("Enrolling ID #");
  Serial.println(id);
  while (!  getFingerprintEnroll() );
}

uint8_t getFingerprintEnroll() {

  int p = -1;
  Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id);
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println(".");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      break;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      break;
    default:
      Serial.println("Unknown error");
      break;
    }
  }

  // OK success!

  p = finger.image2Tz(1);
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }
  
  Serial.println("Remove finger");
  delay(2000);
  p = 0;
  while (p != FINGERPRINT_NOFINGER) {
    p = finger.getImage();
  }
  Serial.print("ID "); Serial.println(id);
  p = -1;
  Serial.println("Place same finger again");
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.print(".");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      break;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      break;
    default:
      Serial.println("Unknown error");
      break;
    }
  }

  // OK success!

  p = finger.image2Tz(2);
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }
  
  // OK converted!
  Serial.print("Creating model for #");  Serial.println(id);
  
  p = finger.createModel();
  if (p == FINGERPRINT_OK) { 
    Serial.println("Prints matched!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_ENROLLMISMATCH) {
    Serial.println("Fingerprints did not match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }   
  
  Serial.print("ID "); Serial.println(id);
  p = finger.storeModel(id);;
  if (p == FINGERPRINT_OK) {
    httpRequest();

    Serial.println  ("Stored!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_BADLOCATION) {
    Serial.println("Could not store in that location");
    return p;
  } else if (p == FINGERPRINT_FLASHERR) {
    Serial.println("Error writing to flash");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }   
   
 
  delay(10000);
}

php code

<?php
include ('connection.php');
$sql_insert = "INSERT INTO student (ID_S) VALUES ('".$_GET["ID_S"]."')";
if(mysqli_query($con,$sql_insert))
{
echo "Done";
mysqli_close($con);
}
else
{
echo "error is ".mysqli_error($con );
}
?>

can u help me … it’s connected to DB but send just zeros

I think you forgot the = sign between the id request variable and the value.

Change:
client.print("ID_S");

To:
client.print("ID_S=");

I would also update your php code to put $_GET[“ID_S”] into a variable and the test (add an if statement) to see if you got a valid value before you to the insert.

1 Like

Lamyaa:
HOW CAN I SAVE FINGERPRINT IN DB .

Before you trek much further: saving fingerprint data for the purposes of taking attendance is a truly terrible idea. For several reasons.

The correct way to do such things is to save a secure hash that represents the fingerprint.

https://www.google.com/search?q=storing+passwords+in+plain+text