Seeding back the field values in html form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsingh
    New Member
    • Sep 2008
    • 2

    Seeding back the field values in html form

    Hi All,
    This is my first post and I am just stuck in my assignment. I am trying to create a single page which basically check whether a name field or text field includes text or not and display message accordingly. There are three field one drop down, two text field.
    Now to access the name field I have to refresh the page I am basically using some php code to validate this field on the top of the form. Now whenever I refresh the page I loose all data but it does display the error message though.

    Now the problem is how I will keep the data in the field and refresh the page.? And display yhe message as well.?

    I have to do this through PHP only.

    Thanx to all....!!!!!!
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    When you say 'refresh' are you sending the form? If so, you can just use the $_POST array to fill the fields.

    Comment

    • gsingh
      New Member
      • Sep 2008
      • 2

      #3
      Originally posted by Markus
      When you say 'refresh' are you sending the form? If so, you can just use the $_POST array to fill the fields.
      Hi markus.
      Thanx for the reply, is it possible to set value of fields in html through php. I had looked around in the internet but i didnt find a way i can set field value through php.

      Please guide //


      Thanx

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by gsingh
        Hi markus.
        Thanx for the reply, is it possible to set value of fields in html through php. I had looked around in the internet but i didnt find a way i can set field value through php.

        Please guide //


        Thanx
        You set the value of an input by the value attribute
        Code:
        <input type="text" value="some value" />
        You could set the value by php, assuming the POST array contains data, by doing this:
        Code:
        <input type="text" value="<?php if(isset($_POST['value']){ echo $_POST['value'];}?>
        You would obviously have to adapt this.

        Comment

        Working...