close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

MySQLi Update Record not working as POST

Thread began 6/06/2019 4:02 pm by Ralph | Last modified 6/07/2019 12:49 pm by Ray Borduin | 22 views | 4 replies |

Ralph

MySQLi Update Record not working as POST

Hello,

I built a form on a page (a1.php) that has a repeat table that lists each distinct user from the database. The form will post to a second page (a2.php), listing the record in a form for record updating. On the second page, I have a form that lists the user record fields, pre-populated that can be changed - some of the fields are read-only.

The Page 1 works well and lists the various users. On submit it loads the Page 2 well and lists the user (that was selected from Page 1) well, with fields pre-populated and ready for modifications.
When I click to "Update record" it does not save any of the changes, nor return me to the referring page. It stays on the Page 2, and shows blank input fields.

In the WebAssist Update Record settings, I set the trigger to "Current page submit". I tried the "any form post", but then the Page 2 would never show at all...

I am sure that this is probably a simple error I am making somewhere, but I cannot figure out how to correct it. I have attached the code from the two files for your review.

As a side note: I had created a page in the past that used URL parameters instead of a form post from page 1. Page 2 would GET the results and all worked fine. The problem is that I cannot allow users to see the URL parameters and thus created the POST form on page 1 to invisibly pass the variable to page 2.
For example, in the Page 1 table, I included a cell that passed the URL parameter:
<td><a href="ent_int_archive_user_edit_detail.php?recordID=<?php echo ($Recordset1->getColumnVal("UserID")); ?>"> EDIT</a></td>
Then in Page 2, I used the WebAssist Update Record setting with "any form post" and all worked well.
For some reason, Page 2 does not update records after I submit the Page 2 form (after I changed the method from GET to POST).

Could you please help me to correct this problem?

Thank you very much for your help and advice.

Sign in to reply to this post

Ray BorduinWebAssist

The way you have your a2.php set up, it is filtering a recordset based on a $_POST['recordID'] value from the first page. The update is set up to update the record displayed in the recordset.

However, after the submit, the $_POST['recordID'] value will no longer exist.

The easiest solution at this point is to add a hidden form element name="recordID" and set its value to the UserID in the recordset so it will persist when the form submits again.

I'd also update the trigger value in the update server behavior to use the button press event instead of the current page submit. Current page submit verifies it is the current page from the referrer in the header and that can sometimes be blocked.

Sign in to reply to this post

Ralph

Hello Ray,

I went ahead and made the changes you suggested, and added this line to the form:
<input type="hidden" name="recordID" value="<?php echo($Recordset1->getColumnVal("UserID")); ?>" />

Thank you for the suggestion. I added the following line just below the form:
<button type="submit" form="updateform" value="Submit">Update Records</button>

I am not sure how to add this to the trigger event. Clicking on the lightning does not show an option for the button event.

Thank you very much for your help.

Best regards,

Ralph

Sign in to reply to this post

Ray BorduinWebAssist

Give the button a name="updateButton" attribute, then open the update record server behavior and click on the Trigger Dropdown. The button press event should show there.

Sign in to reply to this post

Ralph

Hello Ray,

This worked like a charm! Thank you very much for your help on this.

Your products and service are excellent!

Take care and best regards,

Ralph

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...