Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Default value not showing in form feild

Engaged ,
Jun 14, 2012 Jun 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.

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

TOPICS
Server side applications
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 14, 2012 Jun 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 14, 2012 Jun 14, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2012 Jun 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 19, 2012 Jun 19, 2012

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

Their login feild is on the same form as all the other feilds..

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

Ok let me try and explain better what i am trying to do. i have an application form with many fields. included in the fields is the username and password. The user may not be able to complete the form as they may not have some information they need. So i need to be able to save the application to the DB.

the save button needs to send the information to the DB and then send them to a new page. the submit button needs to check all the feilds are complete and if they are it needs to send them to a new payment page.

I have jquery alerts set up and they work. the submit and payment works if all the records are complete.

i hope this is clearer

thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2012 Jun 19, 2012

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 19, 2012 Jun 19, 2012
LATEST

im sorry i dont understand what you mean, im probably being a bit dim. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines