Solved

Login Submit - No Page Refresh

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
javascript: add id amounts 5 47
Remove Black Diamond with Question Mark from Wordpress Custom Meta 6 60
error log using ftp 7 41
Google Maps API and PHP 25 30
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

773 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