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

write session after validation

Thread began 4/27/2009 10:52 am by carsten299415 | Last modified 4/29/2009 5:09 am by carsten299415 | 3011 views | 12 replies |

carsten299415

write session after validation

hi,

for my checkout form i have inserted some SS formvalidations.
In the form i use also a eC_SameAs checkbox to copy the values from billing to delivery inputs. The copy Process works fine. But after the validation the values from the input fields that have been copied from the eC_SameAs have not been written into my sessions.

Can anybody help?

Here is some code:

<?php require_once("WA_ValidationToolkit/WAVT_Scripts_PHP.php"); ?>
<?php require_once("WA_ValidationToolkit/WAVT_ValidatedForm_PHP.php"); ?>
<?php
$XOX_Shop->GetContent();
?>
<?php
$_SESSION["re_plz"] = (ValidatedField("checkoutstep1","postcode"));
$_SESSION["re_stadt"] = (ValidatedField("checkoutstep1","city"));
$_SESSION["re_strasse2"] = (ValidatedField("checkoutstep1","street2"));
$_SESSION["re_strasse1"] = (ValidatedField("checkoutstep1","street1"));
$_SESSION["re_fax"] = (ValidatedField("checkoutstep1","fax"));
$_SESSION["re_telefon"] = (ValidatedField("checkoutstep1","phone"));
$_SESSION["re_email"] = (ValidatedField("checkoutstep1","email"));
$_SESSION["re_name"] = (ValidatedField("checkoutstep1","lastname"));
$_SESSION["re_vorname"] = (ValidatedField("checkoutstep1","firstname"));;
if(isset($_POST['eC_SameAs'])&&($_POST['eC_SameAs'] == true)) {
$_SESSION["li_plz"] = (ValidatedField("checkoutstep1","postcode"));
$_SESSION["li_stadt"] = (ValidatedField("checkoutstep1","city"));
$_SESSION["li_strasse2"] = (ValidatedField("checkoutstep1","street2"));
$_SESSION["li_strasse1"] = (ValidatedField("checkoutstep1","street1"));
$_SESSION["li_fax"] = (ValidatedField("checkoutstep1","fax"));
$_SESSION["li_telefon"] = (ValidatedField("checkoutstep1","phone"));
$_SESSION["li_email"] = (ValidatedField("checkoutstep1","email"));
$_SESSION["li_nachname"] = (ValidatedField("checkoutstep1","lastname"));
$_SESSION["li_vorname"] = (ValidatedField("checkoutstep1","firstname"));
} else {
$_SESSION["li_plz"] = (ValidatedField("checkoutstep1","shipping_postcode"));
$_SESSION["li_stadt"] = (ValidatedField("checkoutstep1","shipping_city"));
$_SESSION["li_strasse2"] = (ValidatedField("checkoutstep1","shipping_street2"));
$_SESSION["li_strasse1"] = (ValidatedField("checkoutstep1","shipping_street1"));
$_SESSION["li_fax"] = (ValidatedField("checkoutstep1","shipping_fax"));
$_SESSION["li_telefon"] = (ValidatedField("checkoutstep1","shipping_phone"));
$_SESSION["li_email"] = (ValidatedField("checkoutstep1","shipping_email"));
$_SESSION["li_nachname"] = (ValidatedField("checkoutstep1","shipping_lastname"));
$_SESSION["li_vorname"] = (ValidatedField("checkoutstep1","shipping_firstname"));
}
?>
<?php
//WA eCart Redirect Check Out
if (isset($_POST["XOX_Shop_Checkout_1_x"]) || isset($_POST["XOX_Shop_Checkout_1"])) {
$Redirect_redirStr="checkout_step2.php";
if ($Redirect_redirStr != "") {
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "") {
if (strpos($Redirect_redirStr, "?") === false) {
$Redirect_redirStr .= "?".$_SERVER['QUERY_STRING'];
}
else {
$Redirect_redirStr .= "&".$_SERVER['QUERY_STRING'];
}
}

$XOX_Shop->redirStr = $Redirect_redirStr;
}
$XOX_Shop->cartAction = "Checkout";
}
?>
<?php
// WA eCart Redirect
if ($XOX_Shop->redirStr != "") {
header("Location: ".$XOX_Shop->redirStr);
}
?>



AND HERE an extract from THE FORM:

<div class="eC_FieldsetWrapper">
<h3 class="eC_CheckoutFormHeader">Lieferadresse</h3>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="eC_SameAsWrapper" >
<tr>
<td><input type="checkbox" name="eC_SameAs" id="eC_SameAs" value="1" onClick="eCart_copyBillingToShipping(this); toggle('box')" style="width:auto;" /></td>
<td><label for="eC_SameAs">Lieferadresse entspricht der Rechnungsadresse</label></td>
</tr>
</table>
<br /><div id="box">
<table border="0" cellpadding="0" cellspacing="0">

<tr>
<th><label for="shipping_firstname" >Vorname*</label></th>
<td><input type="text" name="shipping_firstname" id="shipping_firstname" value="<?php echo $_SESSION['li_vorname']; ?>" />
<span class="Stil1">
<?php
if (ValidatedField("checkoutstep1","checkoutstep1")) {
if ((strpos((",".ValidatedField("checkoutstep1","checkoutstep1").","), "," . "7" . ",") !== false || "7" == "")) {
if (!(false)) {
?>
PFLICHTFELD
<?php //WAFV_Conditional checkout_step1.php checkoutstep1(7:)
}
}
}
?>
</span></td>
</tr>
<tr>
<th><label for="shipping_lastname" >Nachname*</label></th>
<td><input type="text" name="shipping_lastname" id="shipping_lastname" value="<?php echo $_SESSION['li_nachname']; ?>" />
<span class="Stil1">
<?php
if (ValidatedField("checkoutstep1","checkoutstep1")) {
if ((strpos((",".ValidatedField("checkoutstep1","checkoutstep1").","), "," . "8" . ",") !== false || "8" == "")) {
if (!(false)) {
?>
PFLICHTFELD
<?php //WAFV_Conditional checkout_step1.php checkoutstep1(8:)
}
}
}
?>
</span></td>
</tr>
<tr>
<th><label for="shipping_email" >Emailadresse*</label></th>
<td><input type="text" name="shipping_email" id="shipping_email" value="<?php echo $_SESSION['li_email']; ?>" />
<span class="Stil1">
<?php
if (ValidatedField("checkoutstep1","checkoutstep1")) {
if ((strpos((",".ValidatedField("checkoutstep1","checkoutstep1").","), "," . "9" . ",") !== false || "9" == "")) {
if (!(false)) {
?>
PFLICHTFELD
<?php //WAFV_Conditional checkout_step1.php checkoutstep1(9:)
}
}
}
?>
</span></td>
</tr>
<tr>
<th><label for="shipping_phone" >Telefonnummer</label></th>
<td><input type="text" name="shipping_phone" id="shipping_phone" value="<?php echo $_SESSION['li_telefon']; ?>" /></td>
</tr>
<tr>
<th><label for="shipping_fax" >Faxnummer</label></th>
<td><input type="text" name="shipping_fax" id="shipping_fax" value="<?php echo $_SESSION['li_fax']; ?>" /></td>
</tr>
<tr>
<th><label for="shipping_street1" >Stra&szlig;e*</label></th>
<td><input type="text" name="shipping_street1" id="shipping_street1" value="<?php echo $_SESSION['li_strasse1']; ?>" />
<span class="Stil1">
<?php
if (ValidatedField("checkoutstep1","checkoutstep1")) {
if ((strpos((",".ValidatedField("checkoutstep1","checkoutstep1").","), "," . "10" . ",") !== false || "10" == "")) {
if (!(false)) {

Sign in to reply to this post

Ray BorduinWebAssist

for setting the session variables, don't use:

ValidatedField("checkoutstep1","postcode")

use:
(isset($_POST['postcode'])?$_POST['postcode']:"")

Validated field is only to be used when fields are not validated. Really that means just to temporarily populate the form after failed validation. Anything else should refer to the form directly.

Sign in to reply to this post

carsten299415

No Session after Validation

Hi Ray,

your fix doesn't solve my problem. I think there is a problem between the form validation and the sessions. The validation rules work fine. If i put the following code block outside the "if (isset($_POST["XOX_Shop_Checkout_1_x"]) || isset($_POST["XOX_Shop_Checkout_1"])) {" if block, the validation works, but the Sessions are not displayed in my input fields (i left one reqiered field empty and then i am redirected to the same page i posted from).

Block:
$_SESSION['re_plz'] = (isset($_POST['postcode'])?$_POST['postcode']:"");
$_SESSION['re_stadt'] = (isset($_POST['city'])?$_POST['city']:"");
$_SESSION['re_strasse2'] = (isset($_POST['street2'])?$_POST['street2']:"");
$_SESSION['re_strasse1'] = (isset($_POST['street1'])?$_POST['street1']:"");
$_SESSION['re_fax'] = (isset($_POST['fax'])?$_POST['fax']:"");
$_SESSION['re_telefon'] = (isset($_POST['phone'])?$_POST['phone']:"");
$_SESSION['re_email'] = (isset($_POST['email'])?$_POST['email']:"");
$_SESSION['re_name'] = (isset($_POST['lastname'])?$_POST['lastname']:"");
$_SESSION['re_vorname'] = (isset($_POST['firstname'])?$_POST['firstname']:"");
if(isset($_POST['eC_SameAs'])&&($_POST['eC_SameAs'] == true)) {
$_SESSION['li_plz'] = (isset($_POST['postcode'])?$_POST['postcode']:"");
$_SESSION['li_stadt'] = (isset($_POST['city'])?$_POST['city']:"");
$_SESSION['li_strasse2'] = (isset($_POST['street2'])?$_POST['street2']:"");
$_SESSION['li_strasse1'] = (isset($_POST['street1'])?$_POST['street1']:"");
$_SESSION['li_fax'] = (isset($_POST['fax'])?$_POST['fax']:"");
$_SESSION['li_telefon'] = (isset($_POST['phone'])?$_POST['phone']:"");
$_SESSION['li_email'] = (isset($_POST['email'])?$_POST['email']:"");
$_SESSION['li_nachname'] = (isset($_POST['lastname'])?$_POST['lastname']:"");
$_SESSION['li_vorname'] = (isset($_POST['firstname'])?$_POST['firstname']:"");
} else {
$_SESSION['li_plz'] = (isset($_POST['shipping_postcode'])?$_POST['shipping_postcode']:"");
$_SESSION['li_stadt'] = (isset($_POST['shipping_city'])?$_POST['shipping_city']:"");
$_SESSION['li_strasse2'] = (isset($_POST['shipping_street2'])?$_POST['shipping_street2']:"");
$_SESSION['li_strasse1'] = (isset($_POST['shipping_street1'])?$_POST['shipping_street1']:"");
$_SESSION['li_fax'] = (isset($_POST['shipping_fax'])?$_POST['shipping_fax']:"");
$_SESSION['li_telefon'] = (isset($_POST['shipping_phone'])?$_POST['shipping_phone']:"");
$_SESSION['li_email'] = (isset($_POST['shipping_email'])?$_POST['shipping_email']:"");
$_SESSION['li_nachname'] = (isset($_POST['shipping_lastname'])?$_POST['shipping_lastname']:"");
$_SESSION['li_vorname'] = (isset($_POST['shipping_firstname'])?$_POST['shipping_firstname']:"");


When i put the block into the if clause, then the session values are displayed in the input fields. Then i fill the last required field. the validation runs and i am redirected to the next page. there i display all session values again as text. but the last inserted value is missing.

if i re run the validation, the last session values are not rewritten.

Can u help again?

Greetings, Carsten.

Sign in to reply to this post

Ray BorduinWebAssist

This code to set the session variable should be on the same page as the server validation code, directly below the server validation code and outside of any IF statement.

Sign in to reply to this post

carsten299415

doesn't work

... i have tried everything, i think. Nothing works! I will post you the whole .php.

I hope you can help.

Attached Files
checkout_step1.zip
Sign in to reply to this post

Ray BorduinWebAssist

lines 16-64 should all be after the validatioin, so immediately after what is currently line 101 or immediately before the doctype.

Sign in to reply to this post

carsten299415

nothing helped

... hi again,

i am very sorry, but nothing helps!? Can anybody tell me, how to build a checkout form with SS Validation and writing all values to session variables after everything is validating. These sessionvariables i want to use on my next checkout page and write them into DB.

I have spent 2 days on it and i can't get it working.

Sign in to reply to this post

Ray BorduinWebAssist

One thing that may be causing the problem, make sure that the code:


<?php
// WA eCart Redirect
if ($XOX_Shop->redirStr != "") {
header("Location: ".$XOX_Shop->redirStr);
}
?>

appears below the set session variable code. So when I said to move it directly above the doctype, I should have mentioned this code also has to be moved below both.

So it should be ordered:
Validation Code
Set Session Code
Location Redirect Code

Sign in to reply to this post

carsten299415

i have tried that, too. But it also does not work! I have tried to look into the samplefiles. But they dont use a validation? i can't manage it to work properly :-(

Sign in to reply to this post

Ray BorduinWebAssist

When validation succeeds it should act as if it is not there. So the addition of validation shouldn't break anything. Maybe try adding a session_commit() call before the location redirect. Please attach the current version of the page after making all of the suggested changes and I can see if I can spot any more issues.

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