close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Re-populating form fields.

Thread began 8/17/2009 9:31 pm by Groshko | Last modified 8/18/2009 11:35 pm by Groshko | 3542 views | 2 replies |

Groshko

Re-populating form fields.

Hello,

When I deliberately make a submission that is incorrect, the form will refresh itself with the previous entries for Full Name: , Email: , and Message: (so the user does not need to fill this in again).

The new fields which I created for the phone numbers doesn't insert the previous entry. Would anyone know why?

Many Thanks. G


Below are snippets of my code:


TOP OF PAGE BEFORE HTML
====================
<?php require_once('WA_Globals/WA_Globals.php');?>
<?php require_once("WA_ValidationToolkit/WAVT_Scripts_PHP.php"); ?>
<?php require_once("WA_ValidationToolkit/WAVT_ValidatedForm_PHP.php"); ?>
<?php require_once("WA_Universal_Email/mail_PHP.php"); ?>
<?php require_once("WA_Universal_Email/MailFormatting_PHP.php"); ?>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$WAFV_Redirect = "";
$_SESSION['WAVT_contact_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact_Name"]))?$_POST["Contact_Name"]:"") . "",true,1);
$WAFV_Errors .= WAValidateEM(((isset($_POST["Email_address"]))?$_POST["Email_address"]:"") . "",true,2);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Comments"]))?$_POST["Comments"]:"") . "",true,3);
$WAFV_Errors .= WAValidateLE(((isset($_POST["Security_code"]))?strtolower($_POST["Security_code"]):"") . "",((isset($_SESSION["captcha_1"]))?strtolower($_SESSION["captcha_1"]):"") . "",true,4);
$WAFV_Errors .= WAValidateRX(((isset($_POST["addblock"]))?$_POST["addblock"]:"") . "","/^$/i",false,6);
$WAFV_Errors .= WAValidateRX(((isset($_POST["seconddblock"]))?$_POST["seconddblock"]:"") . "","/^$/i",false,7);
$WAFV_Errors .= WAValidatePN(((isset($_POST["Phone"]))?$_POST["Phone"]:"") . "",true,8);
$WAFV_Errors .= WAValidatePN(((isset($_POST["Mobile"]))?$_POST["Mobile"]:"") . "",true,9);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"contact");
}
}
?>
<?php
if ((($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST))) {
//WA Universal Email object="mail"
//Send Loop Once Per Entry
$RecipientEmail = "".($WAGLOBAL_Contact_Email_To) ."";include("WA_Universal_Email/WAUE_contact_1.php");

//Send Mail All Entries
if ("whyus.php"!="") {
header("Location: thankyou.php");
}
}
?>

FORM AND SCRIPT CODE
=======================
<form action="" method="post" name="emailContact" id="emailContact" onsubmit="">
<div style="width:100%">
<p>
<label for="Contact_Name" >Full Name:</label>
<br>
<span id="sprytextfield1">
<input name="Contact_Name" type="text" class="inputValue" id="Contact_Name" onblur="if (document.getElementById('nameServerError')) document.getElementById('nameServerError').style.display='none'" value="<?php echo(ValidatedField("contact","Contact_Name")) ?>" size="30" />
<br><span class="textfieldRequiredMsg">A value is required.</span></span>
<input name="addblock" type="text" id="addblock" style="display:none" value="" />
<?php
if (ValidatedField("contact","contact")) {
if ((strpos((",".ValidatedField("contact","contact").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<span id="nameServerError" class="textfieldServerError">Please provide your full name.</span>
<?php //WAFV_Conditional contact.php contact(1:)
}
}
}?>
<br />
<label for="Email_address" >E-mail:</label>
<br />
<span id="sprytextfield2">
<input name="Email_address" type="text" class="inputValue" id="Email_address" onblur="if (document.getElementById('emailServerError')) document.getElementById('emailServerError').style.display='none'" value="<?php echo(ValidatedField("contact","Email_address")) ?>" size="30" />
<br>
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
<input name="seconddblock" id="seconddblock" type="text" style="display:none" value="" />
<?php
if (ValidatedField("contact","contact")) {
if ((strpos((",".ValidatedField("contact","contact").","), "," . "2" . ",") !== false || "2" == "")) {
if (!(false)) {
?>
<span id="emailServerError" class="textfieldServerError">Please provide your email addess.</span>
<?php //WAFV_Conditional contact.php contact(2:)
}
}
}?>
<br />
<label for="Phone">Phone:<br>
</label>
<span id="sprytextfield8">
<input name="Phone" type="text" id="Phone" class="inputValue" onblur="if (document.getElementById('phoneServerError')) document.getElementById('phoneServerError').style.display='none'" value="<?php echo(ValidatedField("contact","Phone Number")) ?>" size="30">
<br>
</span>
<input name="addblock" type="text" id="addblock" style="display:none" value="" />
<?php
if (ValidatedField("contact","contact")) {
if ((strpos((",".ValidatedField("contact","contact").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<span id="nameServerError" class="textfieldServerError">Please provide your phone number.</span>
<?php //WAFV_Conditional contact.php contact(1:)
}
}
}?>
<br />
<span id="sprytextfield9">
<label>Mobile:<br>
<input name="Mobile" type="text" id="Mobile" size="30">
<span class="textfieldInvalidFormatMsg">Invalid format.</span></label>
<?php
if (ValidatedField("contact","contact")) {
if ((strpos((",".ValidatedField("contact","contact").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<span id="nameServerError" class="textfieldServerError">Please provide your phone number.</span>
<?php //WAFV_Conditional contact.php contact(1:)
}
}
}?>
</span>
}
}
}?>

...............................................

</form>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur"]});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email", {validateOn:["blur"]});
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {validateOn:["blur"], minChars:10, counterId:"countsprytextarea1"});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "none", {validateOn:["blur"], minChars:<?php echo $WAGLOBAL_Captcha_Characters; ?>, maxChars:<?php echo $WAGLOBAL_Captcha_Characters; ?>});
var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8", "phone_number", {validateOn:["blur"], useCharacterMasking:true, format:"phone_custom", pattern:"(00) 0000 0000", isRequired:false});
var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9", "phone_number", {validateOn:["blur"], useCharacterMasking:true, isRequired:false, format:"phone_custom", pattern:"0000 000 000"});
//-->
</script>

Sign in to reply to this post

Jason ByrnesWebAssist

In the Phone field:

php:
type="text" id="Phone" class="inputValue" onblur="if (document.getElementById('phoneServerError')) document.getElementById('phoneServerError').style. display='none'" value="<?php echo(ValidatedField("contact","Phone Number")) ?>" size="30">





you have set the value to use the validated entries for a field named "Phone Number":

php:
value="<?php echo(ValidatedField("contact","Phone Number")) ?>"




but the name of the form element is "Phone":

php:
<input name="Phone"





The validated entries should match the form name to work properly:

php:
value="<?php echo(ValidatedField("contact","Phone")) ?>"
Sign in to reply to this post

Groshko

thanks

All Good! Thank-you very much Jason.

G

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