SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Help needed in username validation

    Hello

    I got a detail page where the form value are selected and users are allowed to edit in the form inputs and even for new case same form is being used.

    But i got the problem on validation of username after submitting.
    If username already exists in database then error message is displayed which is good for me but in case of update, since the same displayed input needs to be checked and when user tries to save with same username as before it finds the input in database and so again displays error message instead i need it to allow to save. So got no idea?
    Thanks in advance for your concern!

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You need to have some way of telling whether it is a current user updating his details, or a new user registering. The usual way to do this is to have a login system and record that the user is logged in (e.g. using Session) - in this case you would catch this in your ASP code and run the UPDATE code; otherwise you would run the INSERT code.

    That's the basic principle.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx 4 the reply but i have used hidden fields and variable is set empty for new and for update it assigns value according to database. so no session used here. my problem is in validating username on server side. It should satisfy for both new case and update case.
    In case of update user should be able to save his current username but cant save other username if exist in database. for new case username can save any name except it is in database.
    so that was the problem

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Simple. Do a SELECT query on the required new username (whether existing user or new user) - if any results are returned then advise the user that this name is already taken.

    For an existing user, simply do the UPDATE without changing the username if it is already taken, otherwise include the new username too.
    Ian Anderson
    www.siteguru.co.uk

  5. #5
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ya update and insert all process are carried out. its complete. But i m still stuck on validation of username after submitting the form only in the case of update username ( not in new username). he/she should be able to save his own existing username + new username (that doesnot exist in database). since his existing username is also in database select query selects this username also so i get message USername repeated in case of saving same username again. ( new user also uses same form and in case up editing/updating it uses same form ). thank u.

  6. #6
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You DO have a separate ID field for user details, don't you? You DON'T rely on the username as the only unique reference, do you?
    Ian Anderson
    www.siteguru.co.uk

  7. #7
    SitePoint Member
    Join Date
    May 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi, you simply solve that problem with JavaScript PopUpBox means either you use confirm box or Prompt box in Update section area.

  8. #8
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx guys, Just solved the problem. just missed a if else statement hehe... Actually i hav used ajax but i also want to validate after submitting also. Thank u siteguru and thank u sandeepji. nice 2 hear 4m u guys... very supporting. like +1


Tags for this Thread

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
  •