Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Login Submit - No Page Refresh

Posted on 2013-11-13
3
Medium Priority
?
425 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
  • 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 Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
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…
Suggested Courses

783 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