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"> |
Freddz |
Jan 14 2019, 11:54 AM
Post
#2
|
Novice Group: Members Posts: 25 Joined: 7-January 19 Member No.: 26,791 |
So from your side you just cannot send me a solution which just keeps my basic structure?...:
A classic html page with client-verification = attribute 'required' which uses php ONLY for a db insert process? I suppose Ajax is only necessary if I want to use/start a separate php file JUST for the db insert process (but not for building a whole page), isn't it? But if I integrate this php code into an HTML form Ajax might even be avoided!? So THIS solution I was asking for... So you cannot help me here? But I should ask CharlesEF anyway? Is your suggestion that I should write him a direct message?... |
Christian J |
Jan 14 2019, 01:05 PM
Post
#3
|
. Group: WDG Moderators Posts: 9,722 Joined: 10-August 06 Member No.: 7 |
So from your side you just cannot send me a solution which just keeps my basic structure?...: A classic html page with client-verification = attribute 'required' which uses php ONLY for a db insert process? If you want to keep your structure it seems you must either load "../cgi-bin/DBinsert.php" in an iframe or call it with Ajax. QUOTE I suppose Ajax is only necessary if I want to use/start a separate php file JUST for the db insert process (but not for building a whole page), isn't it? Yes, Ajax or an iframe. QUOTE But if I integrate this php code into an HTML form Ajax might even be avoided!? Yes. For example, use this in the HTML form page: CODE <iframe name="foo"></iframe> <FORM NAME="Betrugseingabe" ACTION="../cgi-bin/DBinsert.php" METHOD=POST target="foo"> If you also want a success message, "../cgi-bin/DBinsert.php" must create it as an HTML page in the iframe. But if you use Ajax instead of an iframe you may have greater control over where to place the success message. |
Lo-Fi Version | Time is now: 21st September 2024 - 11:23 AM |