SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    622
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    display old and new values in form

    hi all

    In "change address details" form i m displaying all fields values as

    PHP Code:
    <input type="text" name="user_city" value="<? echo row['user_city']) ?>" />
    <input type="text" name="user_country" value="<? echo row['user_country']) ?>" />
    I m validating the form with php and showing errors through php

    so after click of submit button i want to retain form values and display

    1) new data values entered in input fields (in which user made changes)

    2) old data values from database in which user didnt made any changes


    vineet

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    So what you are saying is you want to display what is currently in the database?

    If so, the code should read roughly:

    do update of new values into db
    select the new row again
    display the new row's values into the form

    If this is not what you mean, then explain further.

  3. #3
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,176
    Mentioned
    63 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by vinpkl View Post
    hi all

    In "change address details" form i m displaying all fields values as

    PHP Code:
    <input type="text" name="user_city" value="<? echo row['user_city']) ?>" />
    <input type="text" name="user_country" value="<? echo row['user_country']) ?>" />
    I m validating the form with php and showing errors through php

    so after click of submit button i want to retain form values and display

    1) new data values entered in input fields (in which user made changes)

    2) old data values from database in which user didnt made any changes


    vineet
    I think you may be referring to if something fails (such as missing a required field), you do not want the user to lose what they have already entered, even if those changes my not yet be stored in the table.

    Depending on how your set up, you may need to set the array of their updates to a session so that it can survive multiple HTTP requests, and then be called later to populate the form again.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •