Jump to content

password


Deivas

Recommended Posts

For example:

My username is : Hello

and my password is : bye.

 

If I enter Hello and bye in the login it says "The submitted login info is incorrect.".

 

But if I change my password to 123, it works.

 

Can anyone tell me whats wrong?

 

do_login.php

<?php
if(empty($_POST)) exit;

include 'config.php';
include_once 'connect.php';

// declare post fields

$post_username = $_POST['username'];
$post_password = $_POST['password'];

$post_autologin = $_POST['autologin'];

  $query = "select username,password from app_members where username='$post_username' and '$post_password'";
  $result = mysql_query($query) or die("Could not query players");
  $result2 = mysql_fetch_array($result);
  if ($result2)
  {
    $_SESSION['username'] = $post_username;

// Autologin Requested?

if($post_autologin == 1)
{

setcookie ($cookie_name, 'usr='.$config_username, time() + $cookie_time);
}

exit('OK');
}
else
{
echo '<div id="error_notification">The submitted login info is incorrect.</div>';
}
?>

 

login.php

<?php
require_once 'config.php';

// Is the user already logged in? Redirect him/her to the private page

if(isSet($_SESSION['username']))
{
header("Location: private.php");
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
  <TITLE>AJAX Login Form</TITLE>

  <META name="Author" Content="Bit Repository">
  <META name="Keywords" Content="ajax, login, form, mootools">
  <META name="Description" Content="A nice & simple AJAX Login Form">

  <script type="text/javascript" src="js/mootools-1.2.1-core-yc.js"></script>
  <script type="text/javascript" src="js/process.js"></script>

  <link rel="stylesheet" type="text/css" href="style.css" />
</HEAD>

<BODY>

<center>

<div id="status">

<fieldset><legend align="center">Authentication</legend>

<div id="login_response"><!-- spanner --></div>

<form id="login" name="login" method="post" action="do_login.php">
<table align="center" width="300" border="0">
<tr>
<td width="80">Username</td><td><input id="name" type="text" name="username"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td> </td>
<td><input type="checkbox" name="autologin" value="1">Remember Me</td>
</tr>
<tr>
<td> </td>
<td><input id="submit" type="submit" name="submit" value="Login">
<div id="ajax_loading"><img align="absmiddle" src="images/spinner.gif"> Processing...</div></td>
</tr>
</table>
</form>
</fieldset>

</div>
</center>
</BODY>
</HTML>

 

if you will need anything else tell me.

Link to comment
https://forums.phpfreaks.com/topic/194362-password/
Share on other sites

<?php
if(empty($_POST)) exit;

include 'config.php';
include_once 'connect.php';

// declare post fields

$post_username = $_POST['username'];
$post_password = $_POST['password'];

$post_autologin = $_POST['autologin'];

  $query = "select username, password from app_members where username='$post_username' and password='$post_password'";
  $result = mysql_query($query) or die("Could not query players");
  $result2 = mysql_fetch_array($result);
  if ($result2)
  {
    $_SESSION['username'] = $post_username;

// Autologin Requested?

if($post_autologin == 1)



{






setcookie ($cookie_name, 'usr='.$config_username, time() + $cookie_time);



}

exit('OK');
}
else
{
echo '<div id="error_notification">The submitted login info is incorrect.</div>';
}
?>

 

You weren't telling it to check password vs the password column.

Link to comment
https://forums.phpfreaks.com/topic/194362-password/#findComment-1022428
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.