Solved

Login Submit - No Page Refresh

Posted on 2013-11-13
3
413 Views
Last Modified: 2013-11-13
Currently my login form resides on it's own page.  I want to change that so it is within a drop down and when user submits it checks to see if valid, if not then return bad username/pass and not refresh the page.

Here is the drop down I've created:
<div id="logindropdown" style="display:none;position:absolute;margin-left:85px;width:222px;height:149px;margin-top:30px;background:url('dashboard/img/loginbox.png') no-repeat;padding:40px 30px 30px 30px;">
            <input type="text" placeholder="Username" name="username" required style="width:127px;padding:5px;">
            <input type="text" placeholder="Password" name="password" required style="width:127px;padding:5px;"><br><br>
            <img src="dashboard/img/signinbtn.png"/>
        </div>

Open in new window


Here is my current login page:
<?php
  define("_VALID_PHP", true);
  require_once("init.php");
  
  if ($user->logged_in)
      redirect_to("/client/dashboard");
	  
	  
  if (isset($_POST['doLogin']))
      : $result = $user->login($_POST['username'], $_POST['password']);
  
  /* Login Successful */
  if ($result)
      : redirect_to("/client/dashboard");
  endif;
  endif;
?>
<?php include("header.php");?>
<div id="msgholder-alt"><?php print $core->showMsg;?></div>
    <div class="box">
      <form action="" method="post" id="login_form" name="login_form">
        <table width="100%" border="0" cellpadding="3" cellspacing="0" class="display">
          <tr>
            <th width="200"><strong>Username:</strong></th>
            <td><input name="username" type="text" size="45" maxlength="20" class="inputbox" /></td>
          </tr>
          <tr>
            <th><strong>Password:</strong></th>
            <td><input name="password" type="password" size="45" maxlength="20" class="inputbox" /></td>
          </tr>
          <tr>
            <td><input name="submit" value="Login Now" type="submit" class="button"/></td>
          </tr>
        </table>
        <input name="doLogin" type="hidden" value="1" />
      </form>
    </div>

Open in new window

0
Comment
Question by:N R
  • 2
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39645626
What is the question?  If your script is going to redirect the client browser anyway, why would you want to go to the trouble of creating an AJAX request?

The general design of a client login is shown in this article.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_2391-PHP-login-logout-and-easy-access-control.html
0
 
LVL 11

Author Comment

by:N R
ID: 39645636
I want to use my new dropdown to check the login against the login page, if it's correct login as normal if not then have it return bad username/pass.
0
 
LVL 11

Author Comment

by:N R
ID: 39645661
Opening new question, I see it wasn't clear above and can't edit now.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now