Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Login Submit - No Page Refresh

Posted on 2013-11-13
3
Medium Priority
?
422 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:Nathan Riley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 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 12

Author Comment

by:Nathan Riley
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 12

Author Comment

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

704 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