close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Default value from DB appears blank before validation occurs

Thread began 2/07/2011 12:38 am by lightwalkercreations361768 | Last modified 2/08/2011 7:34 am by Dave Buchholz | 1168 views | 3 replies |

lightwalkercreations361768Beta Tester

Default value from DB appears blank before validation occurs

Dear WebAssist,

I am having something strange happening using form validation. The validation is working perfectly and if validation fails all the information is still retained which is great. But if I visit the page before filling it in the fields should be filled by information in the database, but all the fields remain empty. I have checked to make sure there is information in the DB and I did attach the records to the validation when it asked and I can see them in the code but the fields always a remain blank.

I have attached the file,

Many thanks as always for your help.

Attached Files
index.php.zip
Sign in to reply to this post

Dave BuchholzBeta Tester

The problem is related to the fact that you are using the session in your check i.e.

php:
<?php echo(isset($_SESSION["WAVT_index_410_Errors"])?ValidatedField("index_410","height"):"".$row_MemberAboutMeRs['MemberHeight']  .""?>



I suspect you have not explicitly closed and unset the session so when you revisit this page if you have had errors previously the check will trigger true and try to display errors rather than false and display the recordset values.

Rather than use the session I perform this function like this:

php:
<?php echo(ValidatedField("index_410","height")?ValidatedField("index_410","height"):"".$row_MemberAboutMeRs['MemberHeight']  .""?>



This removes the reliance on the session and will trigger only when a validation fails.

Sign in to reply to this post

lightwalkercreations361768Beta Tester

Dear Dave,

Thank you for your help. Your suggestion worked really well on the fields, but I can not seem to get it to work on the select/menu. I have pasted the code below.

<select name="Height_ID" id="Height_ID">
<?php
do {
?>
<option value="<?php echo $row_HeightRs['HeightID']?>"<?php if (!(strcmp($row_HeightRs['HeightID'], (isset($_SESSION["WAVT_index_410_Errors"])?ValidatedField("index_410","Height_ID"):"".$row_MemberAboutMeRs['HeightID'] ."")))) {echo "selected=\"selected\"";} ?>><?php echo $row_HeightRs['HeightName']?></option>
<?php
} while ($row_HeightRs = mysql_fetch_assoc($HeightRs));
$rows = mysql_num_rows($HeightRs);
if($rows > 0) {
mysql_data_seek($HeightRs, 0);
$row_HeightRs = mysql_fetch_assoc($HeightRs);
}
?>
</select>

Can you suggest what I need to change

Many thanks for your help

Sign in to reply to this post

Dave BuchholzBeta Tester

This should work for you

php:
<select name="Height_ID" id="Height_ID">

<?php
do { 
?>
<option value="<?php echo $row_HeightRs['HeightID']?><?php if (!(strcmp("strcmp($row_HeightRs['HeightID']", (ValidatedField("index_410","Height_ID")?ValidatedField("index_410","Height_ID"):$row_ MemberAboutMeRs['HeightID'])))) {echo "selected=\"selected\"";} ?>><?php echo $row_HeightRs['HeightName']?></option>
<?php
} while ($row_HeightRs mysql_fetch_assoc($HeightRs));
$rows mysql_num_rows($HeightRs);
if(
$rows 0) {
mysql_data_seek($HeightRs0);
$row_HeightRs mysql_fetch_assoc($HeightRs);
}
?>
</select>
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...