Validating 'required' form page data for save to database, Saving by php code file after succesful validation. Success message on |
Validating 'required' form page data for save to database, Saving by php code file after succesful validation. Success message on |
Freddz |
Jan 7 2019, 08:34 PM
Post
#1
|
Novice Group: Members Posts: 25 Joined: 7-January 19 Member No.: 26,791 |
Hello,
I have a form page where I check the mandatory inputs client-sided by the attribute 'required' (when clicking send button). When all required inputs are done the send button click... 1.) should call a php file 'dbinsert.php' which just contains the save process of the form data to a database. 2.) But the success message should be shown on the SAME page, on top of the form page. How can I implement this process under those 2 conditions? I suppose that the send button's 'action' attrbute should be empty and the php file has to be called via Ajax (within a Javascript function?) !? But unfortunately I fail in implementing THIS specific configuration. Could you help me, please? If so, please specify in your answer all necessary code lines like the form header, the submit button and the Javascript function that executes the Ajax call (and also fires the success message, I suppose)? Thank you so much! The following constellation does not work: * <FORM NAME="Betrugseingabe" ACTION="../cgi-bin/DBinsert.php" METHOD=POST> * <INPUT TYPE="submit" NAME="Absenden" VALUE="Absenden" ID="Schaltflaeche1" formtarget="_self"> |
CharlesEF |
Feb 13 2019, 12:01 PM
Post
#2
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Nothing in 'dbinsert.php' jumps out at me, except the fact that you are open to SQL injection attacks. Since you use mysqli_* you should use parameterized queries. As written 'dbinsert.php' won't send a response when ajax is used. You say no PHP errors are shown? If correct, that means the problem is on the Javascript side. Post the entire ajax function.
I hate google so I can't help you with Chrome (to me Android and Chrome are nothing more than spyware) . |
Freddz |
Feb 13 2019, 09:59 PM
Post
#3
|
Novice Group: Members Posts: 25 Joined: 7-January 19 Member No.: 26,791 |
Nothing in 'dbinsert.php' jumps out at me, except the fact that you are open to SQL injection attacks. Since you use mysqli_* you should use parameterized queries. As written 'dbinsert.php' won't send a response when ajax is used. You say no PHP errors are shown? If correct, that means the problem is on the Javascript side. Post the entire ajax function. I hate google so I can't help you with Chrome (to me Android and Chrome are nothing more than spyware) . My Android phone runs without GAPPS ! But Chrome runs really better and more reliable than Firefox... I can use Firefox as well here, no problem... There you are with the Ajax code. But I didn't change anything at your code... Attached File(s) ajax_post___modified.html ( 1.03k ) Number of downloads: 333 |
Lo-Fi Version | Time is now: 23rd April 2024 - 01:32 PM |