Results 1 to 5 of 5

Thread: User Registration form in php

  1. #1
    Join Date
    Mar 2010
    Posts
    22
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default User Registration form in php

    Hi Everyone,

    I am trying to make a user registration form for a client in which the mandatory fields are username, password(twice) and email address. When a user tries to register then he should be advised if the username is available or not.((this should be inline validation))http://www.ajaxupdates.com/jquery-in...dation-engine/ i.e. user doesnt need to submit the form to know if the username was already taken.
    The next thing the form should do is after submitting the form should send an email (( which is provided by the user)) to activate his account..so that email must have a auto generated key which the user needs to click to get his account activated...

    Any help or any links or tutorials would be highly appreciated

    Thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    This is the sort of thing that PHP is designed to do.
    It's hard to answer your question generally because there are a number of smaller steps, each of which adds up to the whole process. What part is confusing you?

    The basic logic is to have the user submit the form and check if there are errors. If so, display the form again, and if not, then display the confirmation ("email sent" or "user registered", etc).
    Also, if you DO show the form again, be sure to echo the submitted data ($_POST['fieldname']) back as the value of the field from which it was submitted. This way the user won't need to retype everything if there was an error, and they can see what was wrong (rather than just thinking the system is broken-- maybe they made a typo).

    For checking errors, it's fairly basic: see if the submitted field matches a certain pattern: if something isn't blank ($var!=''), if it contains numbers and letters (regex*), if it's not too long or too short (strlen()), or that it isn't already used in the database (compare it to a database query).

    For more complex matching like maybe checking an email address, you may need to use regex (regular expressions) a type of code for pattern matching. They're complex, but for commons stuff (like email format) you can find a lot on google.


    So go through error checking and if you find an error store that in a variable somewhere along with a message if you're like. I use $errors[] = 'message here';

    Then at the end you see if there are any errors: if (isset($errors)) {....
    Then just follow the logic at the beginning of the post: continue if no errors, if not just display the form again while echoing the values back AND display errors to the user if you'd like.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Mar 2010
    Posts
    22
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default

    Thanks for the reply,

    I am working with magento where they have there user forms. And I want to extend the form with few of my own fileds.
    the code is here:http://dpaste.com/198792/

    So if you could help me/guide me using the inline validation

    http://www.webresourcesdepot.com/inl...n-with-jquery/

    m a newb in php and want to know how to integrate this inline validation form in the magento's register form.

    Thanks

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    jQuery is not PHP... what do you want?

    You can use both-- use Javascript (if possible) as a first try to get things verified, then use PHP if JS didn't stop it for some reason; but you do need the PHP so that you have a secure way to do it-- JS is not entirely reliable and if someone wants to get around it, it's not hard to do that.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    I think maybe you're looking for an ajax solution - but if you're not comfortable with both PHP and javascript, you're not ready for that. The basic ajax idea is that you use javascript to make an http request to the server, which (typically via PHP) sends back the requested info and javascript loads it into the page without a full refresh.

    So, you'd need to decide which parts of your page will be ajax'd (your [username] field, for example) and write a PHP script to handle the request (checking if the name is available) and send back the answer for javascript to load into the field.

  6. The Following User Says Thank You to traq For This Useful Post:

    andysam (05-28-2010)

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
  •