472,330 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,330 software developers and data experts.

How to automatically insert data to mysql database without submit button in php?


I need help...
How to automatically insert data to mysql database without submit button using php?
Is there a way on this?

thanks a lot.
Dec 1 '09 #1
17 17146
6,050 Expert 4TB
You'll have to be more specific. Can you present an example scenario?
Dec 1 '09 #2
8,658 Expert Mod 8TB
to answer the question verbatim (though that probably won’t help), the PHP script does not care, how the data are delivered, as long as they are delivered (somehow). although I guess if it is about user input, a form (with submit button) is definitely the easiest and most straightforward approach.
Dec 1 '09 #3
9,735 Expert Mod 8TB
Hi Msmjsuarez,

When should your data be inserted into the database?

It probably shouldn't happen when the user is in the middle of providing updated data...so how can you tell when the data should be inserted?

An easiest approach is to use a submit button, but you could always use JavaScript to determine if the user is finished editing. Once the user's finished you could use Ajax to submit the information to the server.

The hard part is going to be determining when the user is finished....when it is appropriate to submit the information.

Also, sometimes users have JavaScript and Ajax disabled so this may cause a problem with your web page. Use the <noscript> tags if you really want to take this approach.

Dec 1 '09 #4
hi everyone.

I have one textbox only in a page and the value of the textbox will obtain through the swipe of the barcode.
The scenario here is that i want to automatically insert the barcode into the mysql database after it is being swiped by the user. More specifically, they will not hit enter anymore after swipe their barcode, it will just automatically inserted to the database.
How to do this?

Thanks advance guys.
Dec 2 '09 #5
1,584 Expert 1GB
Ok, still you have to know when they're done entering the number. The bar code scanner works just like a keyboard, it just types for you.

So let's say you type in a bunch of numbers, when should you know it's done typing?

If the length of the bar code digits are fixed (e.g. 10 digit number), then the following may be a solution:

Having a javascript look inside the text box every time something is entered (the value is changed), and if it is 10 characters long, validate it, and send it off using AJAX, and then clear the textbox to be ready for the next entry.

If you have variable length product codes, then maybe a time solution. Every 2 seconds the box is checked for a value and is sent off if it's different than the last sent value.

You should have a manual mode, where if the bar code is damaged, the operator can hand type the product code into it and press enter.

Good luck,

Dec 2 '09 #6
hi dlite922.

do you have any codes for this?

thanks advance.
Dec 2 '09 #7
hi msmjsuarez -
how are you planning on doing this? Is it going to be based on a fixed length of the barcode number, or a timed interval?

are you going to use javascript?
It seems like you're going to have to use javascript here.
Maybe try coding something and post it here?

Dec 2 '09 #8
Expand|Select|Wrap|Line Numbers
  1. <html> 
  2.   <head> 
  3.   <title>HOW TO: Beep when text field full Using Javascript</title> 
  4.   <meta name="author" content="Shannon Norrell"> 
  5.   <script language="javascript"> 
  6.     function DoCheckLength(aTextBox) { 
  7.       if (aTextBox.maxLength - aTextBox.value.length==0) { 
  8.         document.theForm.submit(); 
  9.         //beep.play(); 
  10.       } 
  11.     } 
  12.   </script> 
  13. </head> 
  14. <body> 
  15.   <FORM NAME="theForm" action=index.php> 
  16.     <input type="text" maxlength="12" size="12" 
  17. onkeyup="DoCheckLength(this);" ID="firstTextBox" name="firstTextBox"> 
  18.     <input type="hidden" maxlength="5" size="5" 
  19. onkeyup="DoCheckLength(this);" ID="secondTextBox" NAME="secondTextBox"> 
  20.   </FORM> 
  21.   <EMBED id="beep" SRC="beep.wav" NAME="beep" AUTOSTART="FALSE" 
  23. </body> 
  24. </html>
Dec 2 '09 #9
That's a great solution...just try to develop.
Dec 2 '09 #10
....would you like me to code the whole thing for you?
Dec 2 '09 #11
No captainB.

Thanks a lot...

i'm also a developer and trying to explore such things.


thanks again.
Dec 2 '09 #12
at any rate, if you know the length of the barcode, it should not be too hard to have the info posted back to the server right away, using ajax, or just the post method of the form...
Dec 2 '09 #13
I got it already..
thanks :)
Dec 2 '09 #14
1,584 Expert 1GB
I hope you meant this as a joke or trick question. It's again site policy.

msmjsuarez has it right. We want the members to explore their own solutions based on our advice.

Dec 2 '09 #15
yea, it was a joke....but not a very good one I guess :)
Dec 2 '09 #16

Is it possible to insert data to two tables at one time using one form only?

I'm using php and mysql.

Thanks advance.
Dec 3 '09 #17
In your server-side code you can run two separate SQL INSERT statements when the form is posted, one for each table.
You can also execute a stored procedure and pass it your form values, and have it insert the values to two tables or more.

If you need more help, maybe you can post some more information, like -
what are the FORM values you are inserting?
What is the table structure of these 2 tables?

Good luck!
Dec 3 '09 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Nomen Nescio | last post by:
can anyone be so kind as to look at http://www.mysolution.ws/HYPOCRITE.php and let me know why it isn't passing the form data to ...
by: Luis | last post by:
Application X has three screens. The user captures information on screen one and then clicks a navigation button to go onto screen two. He does the...
by: Brian Conway | last post by:
Can anyone give me a quick little break down of what I would need to do to insert information into a database onClick of and Submit button? I am...
by: Stephen V | last post by:
Can anyone help me out with this problem. I would like to redirect/ go to another php page when my SQL insertion is done and also send a variable...
by: MrHelpMe | last post by:
Hello experts, O.k I give up on this. I have an LDAP query from asp working correctly. It is returning data fine. Now I need to know how to...
by: andrewtayloruk | last post by:
I'm a newbie when it come to things php and i'm having a bit of trouble. I'm trying to insert data from an html form into a mysql database and...
by: andrewtayloruk | last post by:
Hi i was wondering if anyone could help.... I have made a little script that puts whatever a user enters into a mysql database. As well as the forms...
by: adamace5o | last post by:
When i try to use post variables with php and mysql i can't get the insert into statement to accept varibles as values. If i use 'test' instead of...
by: brianrpsgt1 | last post by:
I am attempting to insert data from a HTML form using a .psp script. I can not find how to link the data that is inserted into the form to the...
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.