Validations stopped working
Can anyone tell me how to use WA to update a mysql column ONLY IF the form is is not empty?
Thanks.
Can anyone tell me how to use WA to update a mysql column ONLY IF the form is is not empty?
Thanks.
Validation toolkit can be used to accomplish this:
validation-toolkit/
You can use either Client Side or Server Side Validation, but server side is more secure since Client Side Validation uses javascript which can be disabled in the browser.
Could you give an example? I couldn't find specific documentation on this.
Basically, and I have a multi-field form, including an image upload, that uses WA UPDATE. I just want to set it up so that if any of the non-required fields are left blank, existing data doesn't get overwritten with empty strings.
I'm getting tripped up somewhere.
Thanks.
An update form would have a recordset that pulls the data that was in the database for that record and set the form fields so that they initial have the value form the record set.
If you want an example of this, run the DataAssist wizard and examine the update page that is created.
You want the form fields to contain the data from the recordset when the page is loaded. This way, all the original data is added back and any changed data is updated.
Sorry, perhaps I wasn't clear. The only issue I am having is with the photo upload field on an "update profile" page that is part of a registration system. All other fields fill and update as they should. But the photo field is not required, so it may be left empty. If someone has already uploaded a file and does not want to upload a new one, the original filename in the database gets overwritten (empty) when the update form is submitted. My question is, how do I avoid this?
Right now, this is the code for the file upload field:
<input class="noformstyle" type="file" name="UserPhoto" id="UserPhoto" size="30" value="<?php echo $row_WAATKusers['UserPhoto'] ?> ">
Thanks.
Ahhh, now I see the problem.
A file field cannot be assigned a value.
The basic idea is to create hidden form element, the initial value for the hidden element comes from the recordset. In the DFP Upload behavior, bind the default file option to the hidden form element. If no file is uploaded, it will use the default file value.
See the "How to apply Digital File Pro to DataAssist Insert and Update pages" tutorial on the How to section of the DFP Support page for more details:
digital-file-pro/
I have followed the instructions in the file you linked to, but am still unable to get this to work. (Also, there is no "Server File Name" option).
Here's my code:
?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFile("WA_UploadResult1", "UserPhoto", "".((isset($_POST["UserPhotoDefault"]))?$_POST["UserPhotoDefault"]:"") ."", "../../../dB/ScientistPhotos/", "[FileName]", "0", "[FileName]_[Increment]", "500", "false", "0", "0");
}
?>
....
<input type="hidden" name="UserPhoto" id="UserPhoto" value="<?php echo $row_WAATKusers['UserPhoto'] ?> ">
<input class="noformstyle" type="file" name="UserDefaultPhoto" id="UserDefaultPhoto" size="30" >
What am I missing?
Apologies - I mistyped the second part.....the code is:
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1") ;
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFile("WA_UploadResult1", "UserPhoto", "".((isset($_POST["UserPhotoDefault"]))?$_POST["UserPhotoDefault"]:"") ."", "../../../dB/ScientistPhotos/", "[FileName]", "0", "[FileName]_[Increment]", "500", "false", "0", "0");
}
?>
....
<input type="hidden" name="UserDefaultPhoto" id="UserDefaultPhoto" value="<?php echo $row_WAATKusers['UserPhoto'] ?> ">
<input class="noformstyle" type="file" name="UserPhoto" id="UserPhoto" size="30" >
It is difficult to tell without seeing the code for the entire page.
Please compress the page ito a zip archive and attach it to your reply.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
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.