Automatically insert into mysql when reading barcode

Asked

Viewed 215 times

1

I’m trying to create an internal project to record employees' tasks with barcode reading. Right now I have an example of code to read the code and submit in the database table.

Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Registo de Tarefas</title>
<script type="text/javascript">
function submeter(){
document.coder.submit()
}
</script>
</head>

<body>

<?php if(isset($_POST['codigo']) && $_POST['codigo']!=''){
echo "<script>alert('".$_POST['codigo']."');</script>";
}
else
{
?>
<form name="coder" action="" method="post">
<input type="text" name="codigo" onfocus="if(this.value.length==10){submeter()}" maxlength="10" onchange="if(this.value.length==10){submeter()}"  onkeyup="if(this.value.length==10){submeter()}" onblur="if(this.value.length==10){submeter()}" />
</form>
<?php
}
?>
</body>
</html>

Now I intended to do the insert in a more automatic way, where the collaborator when reading the barcode with the scanner makes the insert automatic in the database table, without having HTML fields and without having to scroll to the pc, only the scanner is networked.

Add information to the question:

I’m not asking how to do the insert and the connection to mysql. The question I’m asking is how to do the insert automatic when reading barcode without form.

Example:

When reading the barcode with the scanner, the code is inserted into the database automatically, without having to use a form. The scanner is networked, and when writing the code it reads, write it directly into the database table. I don’t know if it’s possible to do what I want.

  • @Anderson Carlos Woss the question that you associated with my question as a possible duplicate, is very different from what I’m asking. I do not intend to find the answer how to insert and connect to mysql, I intend to do direct communication between the barcode reader and mysql, I do not know if it is possible

  • Bruno, then I will continue with my opinion that it is duplicated. There in the answer I comment on the concepts you need to know to pass any value of your page to the database - which is exactly the problem you are facing. There is no magic in the programming. Read there all the concepts you need to study and you will know how to solve your problem.

  • @Anderson Carlos Woss was reading his entire answer and I got the knowledge of several concepts that I did not know, very complete the information. But I was left with a question about what I want. I ask, for the web server to run php there must always be a form? Or the web server where you run php can interpret the input of barcode reader data without form?

  • Bruno, if the reader is connected directly to the web server it is possible to do something like this, yes. If it is connected to another computer, you will need to send the information over the network - but it depends on your infrastructure and the requirements of the project, getting very broad to discuss here. Through the form is one of the forms (possibly the simplest).

  • @Anderson Carlos Woss, the readers will be connected to the computer of the web server, are two readers, but I still can not see how I can do.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.