Skip to main content
Inspiring
June 14, 2012
Question

Default value not showing in form feild

  • June 14, 2012
  • 6 replies
  • 1639 views

I have entered a default value "required" into a phpMyAdmin DB when i open up the form on the website that the feild relates to the default value is not showing up in the form.

I dont want to put the default "required" in value in the  <input type="text" name="GuEmployerEmail" value="required" size="30" />

as i have an input form and an update form (seperate forms but the same DB)

<input type="text" name="GuEmployerEmail" value="<?php echo htmlentities($row_Recordset1['GuEmployerEmail'], ENT_COMPAT, 'utf-8'); ?>" size="32" />

if you need code i can post

thanks in advance

This topic is closed to new replies. Start a new post to keep the conversation going.

6 replies

Participating Frequently
June 14, 2012

>I have entered a default value "required" into a phpMyAdmin DB when i open up the form

>on the website that the feild relates to the default value is not showing up in the form.

Where do you want this - on the insert form or update form? If insert form, that implies that the row has not been inserted, so there is no default value set.

A database default value is populated into the database column during an insert when a NULL value is supplied. If that row has been inserted and you are populating form field from it, then whatever value is in the database will be presented in the form. Sounds like you want something different to happen.

Why don't you want to hard code "Required" directly into the form field value?

Inspiring
June 15, 2012

>>>>>Where do you want this - on the insert form or update form? If insert form, that implies that the row has not been inserted, so there is no default value set.

i have added the required feild on the update form and this is working

>>>>>A database default value is populated into the database column during an insert when a NULL value is supplied. If that row has been inserted and you are populating form field from it, then whatever value is in the database will be presented in the form. Sounds like you want something different to happen.

>>>>>>Why don't you want to hard code "Required" directly into the form field value?

i have two forms and i thought that was the best way of doing it

Let me explain the full process of the form. They can either apply using a form from the start MM_insert POST. They enter all the information ( if they don't have the information i want them to be able to return at later date to input). They have to enter a username and password to be able to access their account to continue to edit the form.


if they complete the form straight away it takes them to the next page and all sorted. However...


if they want to save the form this is where they have to enter their user details then login and access the form ( which is a different page to the first POST form) this in an GET MM_update. So i need to have data in the db feilds saying "required" so the form passes.

Participating Frequently
June 18, 2012

OK, I really don't fully understand the workflow. And is the field in question their login id, or just an additional field?

I'll take a wild guess here. If they are completing the form but not filling in the GuEmployerEmail field, and your insert statement is inserting into that field, then it will insert an empty string and the default value would not be populated. You could test the value in that field and adjust the insert statement accordingly, but I wouldn't even bother. When you retrieve the record to populate the form, just test that value in the recordset - if it's null or emply (or not a valid email address) then populate the form field with "Required".

Sorry if this is off the mark, but it's hard to tell what you are trying to do here.