Solved

Login Submit - No Page Refresh

Posted on 2013-11-13
3
414 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

895 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

17 Experts available now in Live!

Get 1:1 Help Now