Jump to content

Trouble with password script


JLitkie

Recommended Posts

hey guys I have a script I have used on my internal server for a couple years now and its worked just fine.  I appliedit to a recent script online and it is not processing correctly.  i was wondering if I might be able to get a second set of eyes on this one.  Thanks guys.

 

<?php

session_start();

$_SESSION['username'] = $_POST['username'];

if(isset($UserName2) == FALSE)
{
$UserName2 = 'none';
}
Else
{
}

$UserName = $_POST['username'];
$Pass = $_POST['password'];

include("database.php");

mysql_select_db("bluemoonmastiff", $con);

$result = mysql_query("SELECT * FROM Password WHERE username='$UserName' AND password='$Pass'");

while($row = mysql_fetch_array($result))
{


$UserName2 = $row[3];
$Pass2 = $row[4];


}


if($UserName == $UserName2 AND $Pass == $Pass2)
{

include("database.php");

mysql_select_db("bluemoonmastiff", $con);

  $good_data = $_POST;
  
  foreach($good_data as $field => $value)
  {
    if($field != "submitted")
{
   $field_array[] = $field;
   $clean = strip_tags(trim($value));
   $escaped = mysqli_real_escape_string($cxn,$clean);
   $value_array[] = $escaped;
}
  }
  
  $fields = implode(",",$field_array);
  $values = implode('","',$value_array);
  $sql = "INSERT INTO signin ($fields) VALUES (\"$values\")";
  
  	if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

include("Indexmain.php");

}

else
{

    include("Index.php");


}


?>



Link to comment
https://forums.phpfreaks.com/topic/203497-trouble-with-password-script/
Share on other sites

it doesnt give an error, it just wont process to grant access.  It keeps pulling back as incorrect username and password.  Its acting like it cant pull the information from the database to us the IF coding to compare it. and grant the access to the page.

So, you are having a comparison that is failing to match the values in some variables. Why don't you echo (or use var_dump() on) the variables being compared to find what they actually contain. Then troubleshoot why the variables(s) don't have the expected values.

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.