close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to set the value of a field to the database content and then the validated entry?

Thread began 1/26/2016 11:42 am by Nathon Jones Web Design | Last modified 6/06/2016 1:36 pm by Ray Borduin | 278 views | 24 replies |

Nathon Jones Web Design

How to set the value of a field to the database content and then the validated entry?

Here is a standard text input field for our INSERT form which displays the data entered by the user should validation fail:

<input name="FRcompanyTITLE" type="text" required class="form-control" id="FRcompanyTITLE" tabindex="1" value="<?php echo(ValidatedField("addcompany_937","FRcompanyTITLE")) ?>">



For our UPDATE form though I need the value to, initially, be the data from the recordset:

<?php echo($rsEDITCOMPANY->getColumnVal("FRcompanyTITLE")); ?>



...but upon validation, should any validation fail, I need it to reflect any changes that the user has made.
Can I combine the validation and recordset data for the input fields value? Would appreciate an example, if indeed it's possible.
Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

Add a url parameter to the fail redirect in the server validation like: page.php?fail=1

Then you can set the value of the input based on that value like:
<?php echo(isset($_GET['fail'])?ValidatedField("addcompany_937","FRcompanyTITLE"):$rsEDITCOMPANY->getColumnVal("FRcompanyTITLE")); ?>

So if it sees fail in the url it uses the validatedfield value, otherwise it uses the value from the recordset.

Sign in to reply to this post

Nathon Jones Web Design

Any reason why this would just stop working for no apparent reason? Please see attached, and also a link in the private section below.
To break the validation, try entering "Title <>" in the Headline Title field.
Once you click submit, all the field data is gone - both the validation and the recordset. :(

...yet it still shows the validation errors! Urrghh.

Hope you can help. Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

It looks like you have updated your form element names.

For instance on line 147 you have: ValidatedField("editnews_784","DGCRCnewsTITLE")

but the field name is just "newsTITLE", so it should be: ValidatedField("editnews_784","newsTITLE")

It looks like you need to go through and remove "DGCRC" from the front of a lot of the field references.

Sign in to reply to this post

Nathon Jones Web Design

Thank you Ray.

I've corrected that (stoopid) mistake however certain fields are still misbehaving.

1) The "Full Text" HTML editor form field deletes the value despite this:

<textarea class="form-control" id="newsSUMMARY" name="newsSUMMARY" rows="3" placeholder="Describe the news article in one paragraph..." tabindex="4" required><?php echo(isset($_GET['enewsval'])?ValidatedField("editnews_784","newsSUMMARY"):$rsEDITNEWS->getColumnVal("DGCRCnewsSUMMARY")); ?></textarea>



2) When the UPDATE form initially loads, it displays the images (in the Photographs) section. I have un-hidden a usually hidden text field for storing of the default image file reference and it is displaying the correct file name. However, upon a validation fail the images disappear and the hidden img field reference is blank.

<fieldset class="form-group">
<?php if ($rsEDITNEWS->getColumnVal("DGCRCnewsIMG1") <> "") { ?>
<img src="images-news/<?php echo($rsEDITNEWS->getColumnVal("DGCRCnewsIMG1")); ?>" class="img-fluid img-thumbnail">
<?php } ?>
<label for="newsIMG1">Main Photograph</label>
<input type="file" class="form-control-file" id="newsIMG1" name="newsIMG1" tabindex="6">
<input type="text" id="newsIMG1hide" name="newsIMG1hide" value="<?php echo(isset($_GET['enewsval'])?ValidatedField("editnews_784","newsIMG1"):$rsEDITNEWS->getColumnVal("DGCRCnewsIMG1")); ?>">
</fieldset>



3) The same thing is happening with the Document section.

4) Also, if a validation fails a validation error message should appear however when you go back to the seach form and select the news item again, despite it being a new request for hte page the previous validation error is displayed.

Another thing...

I have spotted a problem with the validation when used in conjunction with an INSERT form and the Save ID in Session As feature.
If you add a news item, using the system I've linked to above, and your form has no problems and doesn't fail validation then the Save ID in Session As feature works and, on the confirm page I have set up, you are shown the correct, newly added, article because it is pulling the correct row ID from the database using the ID saved in Session.

However, if you fail validation, make corrections and re-submit the form then it appears that the Save ID in Session As no longer works and you are presented with the first record in the table.

How do I resolve that?

Hope you can help with the above.
Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

Your code has:
isset($_GET['enewsval'])

but your failed validation adds "val" to the url and not "enewsval"... you would have to update that to:
isset($_GET['val']) to match the redirect on line 8.

The issue with the session is that you are redirecting after the update, which would cause the session to never be set because it appears after the update code. Just move the save session code above the update code and it should fix that problem.

Sign in to reply to this post

Nathon Jones Web Design

I'm sure I'd uploaded the latest version, sorry. Try that now (link below) - again search for "Nathon" to find a record to edit.
The validation is most definitely adding "enewsval" to the url, but still the form fields are being wiped.

This also does not address the problem with the INSERT form which, when the validation is triggered, is wiping the Save ID in Session As value so the confirmation page recordset, which uses that session ID isn't displaying the correct record.

Hope you can help. Thank you Ray.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

Please attach a current version of the page. I'll need to look at the php code as well.

Sign in to reply to this post

Nathon Jones Web Design

INSERT and UPDATE forms attached along with the confirmation page Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

The only field that got wiped in my test was the full text field, and you have it set to get the value of:

ValidatedField("editnews_784","newsFULL")

but the field name is newsTEXT not newsFULL.

I don't think the validation would prevent the session variable from being saved. I'd need ftp access to debug that one. Are you sure it works when you don't have a failed validation first?

Sign in to reply to this post
loading

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...