Skip navigation
Currently Being Moderated

Default value not showing in form feild

Jun 14, 2012 1:55 AM

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

 
Replies
  • Currently Being Moderated
    Jun 14, 2012 10:10 AM   in reply to Jonathan Fortis

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 18, 2012 10:27 AM   in reply to Jonathan Fortis

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 10:28 AM   in reply to Jonathan Fortis

    OK, so now what exactly is the problem? Did you read and understand my explanation of why a DBMS default value will not be inserted into the db field if you pass the empty string in the SQL insert statement? Does that answer your question?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points