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

Server Validations losing $_POST values and

Thread began 12/06/2019 4:24 pm by Steve | Last modified 12/09/2019 2:15 pm by Ray Borduin | 231 views | 23 replies |

Steve

Server Validations losing $_POST values and

Couple questions on Server Validations

1) Is there a reason $_POST values are lost on submission?
The server validation works and displays the missing input value but the $_POST is not retained which requires a filling out the form again.

php:
if ($_SERVER["REQUEST_METHOD"] === "POST")  {

  $WAFV_Redirect = "rates-and-availabilityx.php";
  $_SESSION['WAVT_ratesandavailabilityx_517_Errors'] = "";
  if ($WAFV_Redirect == "")  {
    $WAFV_Redirect = $_SERVER["PHP_SELF"];
  }
  $WAFV_Errors = "";
  $WAFV_Errors .= WAValidateRQ(((isset($_POST["contact-name"]))?$_POST["contact-name"]:"") . "",false,1);
  $WAFV_Errors .= WAValidateRQ(((isset($_POST["email"]))?$_POST["email"]:"") . "",false,2);
  $WAFV_Errors .= WAValidateRQ(((isset($_POST["dateArrive"]))?$_POST["dateArrive"]:"") . "",false,3);
  $WAFV_Errors .= WAValidateRQ(((isset($_POST["dateDepart"]))?$_POST["dateDepart"]:"") . "",false,4);

  if ($WAFV_Errors != "")  {
    PostResult($WAFV_Redirect,$WAFV_Errors,"ratesandavailabilityx_517");
  }
}



<input name="contact-name" type="text" class="form-control order-1"
value="<?php if (isset($_POST['contact-name'])) {
echo $_POST['contact-name'];
} ?>"/>



2) Is there a variable that is present that we can use to show an area (or not) IF there are any outstanding server validations still present?
Looking at the generated code it looks like this is the case to use:

php:
<?php  if (isset($WAFV_Errors) && $WAFV_Errors != "")  { ?>


Just looking for a confirmation that this is the best practice method for a generic conditional showing of a wrapper div.

Sign in to reply to this post

Steve

Regarding question 2) I see the preferred method is:

php:
<?php

                    
if (ValidatedField('ratesandavailabilityx_878''ratesandavailabilityx_878')) {
                        if ((
strpos(("," ValidatedField("ratesandavailabilityx_878""ratesandavailabilityx_878") . ","), "," "" ",") !== false || "" == "")) {
                            if (!(
false)) {
                                
?>
Sign in to reply to this post

Ray BorduinWebAssist

The post is cleared to prevent any inserts, updates, emails, or whatever from happening on the page if the validation fails.

You can use the validated field bindings to get the value of the field when validation fails.

I usually add a url parameter to the failed validation redirect and then key off that for update fields or if the form is populated the first time the page is viewed by any method. So:

$WAFV_Redirect = "rates-and-availabilityx.php?fail=true";

Then in your form fields:

<input name="fieldname" value="<?php echo(isset($_POST["fail"])?$_POST["fieldname"]:ValidatedField("ratesandavailabilityx_878", "fieldname")); ?>"

If you don't need the form initially populated then you can use:
<input name="fieldname" value="<?php echo(ValidatedField("ratesandavailabilityx_878", "fieldname")); ?>"

Sign in to reply to this post
Did this help? Tips are appreciated...

Steve

Thanks for the added info Ray but this is frustrating exercise...

Even in the simplest executions, it works partially then not at all then required hand-coding or execution inserts code in unsuspecting locations... And now it looks like it's blocking a jQuery slideToggle

I've attached the page but will continue hacking away and also set your GET and echoing of the ValidatedField values.

Dreamweaver is a frustration these days also and I expect others are having issues with it becoming less predictable. I hope someday there is a stand-alone version that we can use with other IDEs (hint hint). PHPStorm extension maybe?

Attached Files
rates-and-availabilityx.php
Sign in to reply to this post

Ray BorduinWebAssist

What is currently wrong with this page? I'm not sure what I'm looking at.

I see you have form element names with dashes. PHP won't like that. You should probably replace those with underscores.

I'd set the form action to the page name like: action="rates-and-availabilityx.php"

I don't see any other obvious issues. What errors are you getting? Is there a url where I can see the problem?

Sign in to reply to this post
Did this help? Tips are appreciated...

Steve

live test page is: https://hotellecabanon.com/rates-and-availabilityx.php?fail=true

Note it will not do an actual submission so no problems in testing.

What does not work?
The "All" condition loads on default (no submission):
https://hotellecabanon.com/rates-and-availabilityx.php

Then the fields to be validated are not validating. They have in prior iterations but never all. Might be sequencing through the current version does go from nothing (0?) to 5
//WAFV_Conditional rates-and-availabilityx.php ratesandavailabilityx_815(5:)

But now I am concerned this full page re-entering will create considerable problems for the slideTo area which is used to show a calculation of costs on click (but after successfully passing all validations).

Sign in to reply to this post

Steve

I can see why the slideToggle no longer works which is due to the page reloading in a state which is similar to a fresh load.

I'll have to look at some boolean toggle via a $_SESSION value...

To further clarify weird executions, at one point the unique number was not appended when adding a validation. For instance, we would expect this:
if (ValidatedField('ratesandavailabilityx_815','ratesandavailabilityx_815')) {
But one time it set the parameter as :
if (ValidatedField('ratesandavailabilityx','ratesandavailabilityx')) {

Of course, this did not produce a working result and not sure if DW or the Behaviour was at fault (no appended #)

Sign in to reply to this post

Steve

I can give you direct access if you like (FTP). I'll duplicate the page and leave the one referenced alone.

Sign in to reply to this post

Steve

I've made solid progress and have the following to report.
The main problems come from creating server-side validation and then updating or adding to the values/fields being validated.

What happens is that the numeration for the individual identifiers gets jacked up:
Non-sequential additions.
Added spaces in the naming numerations and as mentioned, one time there was no numerical numeration appended at all.

The attached screenshots show how DW and the extension created the code as well as the now working instance where hand-coded changes made things uniform.

For instance, in the following example we see a space inserted before the numeral 4. And the second line is numerated as #2 though it should have been a sequential #5

$WAFV_Errors .= WAValidateRQ(((isset($_POST["dateDepart"])) ? $_POST["dateDepart"] : "") . "", false, 4);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["persons-qty"]))?$_POST["persons-qty"]:"") . "",false,2);


The other screenshot shows the page having met all server-side variables, and now successfully showing a summary of the costs, but losing all it's prior populated field values as the behaviour has successfully processed. So I may need to move to saving the field values as $_SESSIONs or remove the code from wavt_validatedform_php.php or wavt_scripts_php.php that is clearing those prior useful values (example: <?php echo(isset($_POST["fail"])?$_POST["contactName"]:ValidatedField("ratesandavailabilityx_815", "contactName")); ?>).

Lastly and probably a DW issue, when updating, there are multiple cases of the require_once files:

<?php require_once("webassist/form_validations/wavt_scripts_php.php"); ?>
<?php require_once("webassist/form_validations/wavt_validatedform_php.php"); ?>
<?php require_once("webassist/form_validations/wavt_validatedform_php.php"); ?>

Any of these examples where purely DW and Server Validation Behaviour generated.
Latest dev iteration is here: https://hotellecabanon.com/rates-and-availabilityy

Sign in to reply to this post

Steve

Created a new page to test and try to recreate any problems.
https://hotellecabanon.com/test.php

Everything is working predictably... Sorry I can't find some specific case to be able to recreate.

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