Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Feb 2010
    Location
    God's Own Country
    Posts
    87
    Thanks
    6
    Thanked 0 Times in 0 Posts

    checking uniqueness

    Hai Friends..I made a registration form.I have used php,html as well as javascript in it.In the onclick event of submit button I've provided a call to a function written in javascript.Things are working fine i.e validations are working properly and insertion of values to the database is also ok.

    And the problem dat I have is, I want to check whether username and emailid provided is unique with respect to my site...that is no two users can't have same emailid or username.I'm able to retreive the entire emailid and username out of the database.But I don't know where should I place the code for checking the equality.I think that the code should be placed in the javascript validation function..but the code for retreiving values from db is in php.

    I'm totally confused.I'm attaching here the registration page that I made...anyone out there please go through it and help me with a solution.
    Attached Files Attached Files

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    I haven't checked your file, however you can't make a unique check from client side using javascript, without making an AJAX request.

    The easy way for you would be, make all client side validations like Username& Email format from client side(before form submit) and then use PHP code to validate the data (this is a must, since users can bypass client side validation) and check the uniqueness of Username&Email. If everything is OK, insert in to DB, otherwise display the form again and show appropriate message.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Feb 2010
    Location
    God's Own Country
    Posts
    87
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    I haven't checked your file, however you can't make a unique check from client side using javascript, without making an AJAX request.

    The easy way for you would be, make all client side validations like Username& Email format from client side(before form submit) and then use PHP code to validate the data (this is a must, since users can bypass client side validation) and check the uniqueness of Username&Email. If everything is OK, insert in to DB, otherwise display the form again and show appropriate message.
    I've done client side validations for all field using javascript.But, I don't want to do server side validation for every field.But, for my problem to be solved I need to use server side validation...right??So I think that I will validate username and email fields only in php and then check their uniqueness.But I don't know how to do it?can u please help mee??

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Take a look at http://www.astahost.com/info.php/Php...on_t10899.html to see a sample serverside validation. (You may need to replace the deprecated eregi with its preg version)
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Feb 2010
    Location
    God's Own Country
    Posts
    87
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    Take a look at http://www.astahost.com/info.php/Php...on_t10899.html to see a sample serverside validation. (You may need to replace the deprecated eregi with its preg version)
    okkk friend....now I've got some ideas...Let me try ittt...If thing work well I'll let u know...Thanks to youuuuu.

  • #6
    New Coder
    Join Date
    Feb 2010
    Location
    God's Own Country
    Posts
    87
    Thanks
    6
    Thanked 0 Times in 0 Posts
    I tried the other way and everything is okk..But now der is a small problem..on submitting the form, client side validations are working fine but when it come to server side after showing the error message values in the fields are emptied automatically.Hence even if there is error in only one field user has to retype the values in other fields also.

  • #7
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Hence even if there is error in only one field user has to retype the values in other fields also.
    That's the normal behaviour of html forms. All the typed data vanishes on page reload/refresh. Thus, you need to echo the values in $_POST array on the respective form elements.
    Last edited by abduraooft; 03-16-2010 at 02:30 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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