SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile How to create a popup Login Window using PHP?

    Hi There,

    First of all, i would like to say that my experience with this forum is really very good.

    I want to create a popup Login Window for my website.
    You can see one of the example of this here.
    oodle.com---> post add button. (At the right top)

    Can you please let me know, which functionality they have used to achive this. (Javascript or ajax)
    Can i get any readymade *.js or tutorial for same popup window.

    Thank you in anticipation.

  2. #2
    SitePoint Guru Ruben K.'s Avatar
    Join Date
    Jun 2005
    Location
    Alkmaar, The Netherlands
    Posts
    693
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use a Lightbox script for this Not PHP!

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Ruben K. View Post
    Use a Lightbox script for this Not PHP!
    You can't do server side authentication with a lightbox script. You can't do it client side at all with any kind of script.

    You can either use PHP or place the code into .htaccess/.htpasswd files on the server.

    See http://php.net/manual/en/features.http-auth.php for the PHP reference page on how to do it with PHP.

    You can of course make a form that people can't find on your page without first clicking a link using JavaScript and perhaps even a lightbox script but since you need a varsion that works without that for the 10% of visitors without JavaScript and since you still need to authenticate the login server side the server side only solution is the better option.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Guru Ruben K.'s Avatar
    Join Date
    Jun 2005
    Location
    Alkmaar, The Netherlands
    Posts
    693
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    You can't do server side authentication with a lightbox script. You can't do it client side at all with any kind of script.

    You can either use PHP or place the code into .htaccess/.htpasswd files on the server.

    See http://php.net/manual/en/features.http-auth.php for the PHP reference page on how to do it with PHP.
    Obviously he (and I for that matter) meant how to get that overlay box your suggestion comes after that

  5. #5
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you use an AJAX foundation like jQuery or DojoToolkit you can actually authenticate within the lightbox. Both foundations support the lightbox and asynchronous queries. An easier solution may be just to use a drop down login box like Twitter and Digg uses.

  6. #6
    Visible Ninja bronze trophy
    JeffWalden's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,709
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    You can't do server side authentication with a lightbox script. You can't do it client side at all with any kind of script.
    I don't know the specific lightbox technology that Facebook uses, but don't they do server side communication within the lightbox?
    TAKE A WALK OUTSIDE YOUR MIND.

  7. #7
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Most of the lightbox varients support AJAX surely the server side authentification can be driven from there.

  8. #8
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "спасибо за инфу"

  9. #9
    SitePoint Addict
    Join Date
    Jul 2007
    Location
    San Jose, California
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Light box or not, it's not that very hard to do. I'd go about w/ jquery, ajax, and php.

    1. Create a hidden div on the page anywhere you want, i'd suggest using fix and then some offset of where you want. Write the html form here for login.
    2. Create button for login.
    Code HTML4Strict:
    <a href="login.php" class="login">Login</a>
    3. Create Event in Jquery
    Code JavaScript:
    $('login').click(function(e){
    e.preventDefault();  //Stops from following link
    //Add ajax form elements here i suggest this plugin [url]http://malsup.com/jquery/form/[/url]
    });

    Now from that point in step 3 you're going to do some more magic, when the plugin returns from onComplete, validate correctly that the user has logged in then refresh the page, and there you go.

    Now for the 10% of your users who should grow up? Well this even never gets bound so they're taken to login.php.

  10. #10
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by baileylo View Post
    Now for the 10&#37; of your users who should grow up?
    So you can perform miracles and enable blind people to see can you? if not then in what way is it that you expect them to grow up?

    Also how do you propose to perform the miracle of getting the JavaScript to run on devices that don't have a browser that supports it? Presumably you can perform the miracle of making all those older mobile phones grow up into more modern ones?

    There are lots of reasons why people don't have JavaScript enabled.Some people even have it disabled so as to bypass annoying scripts that hide essential info such as login forms.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  11. #11
    SitePoint Addict
    Join Date
    Jul 2007
    Location
    San Jose, California
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Felgall, you make alot of true points:
    1. Yes alot of people do have older phones that dont support javascript.
    2. There are alot of people who have javascript turned off for personal reasons.

    But they are neither here nor there, the solution I presented degrades gracefully when javascript isn't present on the browser as mentioned in my post. As you can see the click that has the javascript event bound to it is an href. Thus if there is no javascript bound to it, the user is taken to the login.php page.

    As to your personal questions to me about my views on javascript and what people should do? I'd be more than glad to answer them in a more appropriate venue, private messages.


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
  •