JLitkie Posted June 1, 2010 Share Posted June 1, 2010 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"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/203497-trouble-with-password-script/ Share on other sites More sharing options...
riwan Posted June 1, 2010 Share Posted June 1, 2010 what exactly the error shown on the screen ? Quote Link to comment https://forums.phpfreaks.com/topic/203497-trouble-with-password-script/#findComment-1066058 Share on other sites More sharing options...
JLitkie Posted June 2, 2010 Author Share Posted June 2, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/203497-trouble-with-password-script/#findComment-1066456 Share on other sites More sharing options...
PFMaBiSmAd Posted June 2, 2010 Share Posted June 2, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/203497-trouble-with-password-script/#findComment-1066457 Share on other sites More sharing options...
kenrbnsn Posted June 2, 2010 Share Posted June 2, 2010 Where is $UserName2 coming from for this "if" statement? <?php if(isset($UserName2) == FALSE) { $UserName2 = 'none'; } Else { } ?> Also, you don't need the empty "else" block, just leave it off. Ken Quote Link to comment https://forums.phpfreaks.com/topic/203497-trouble-with-password-script/#findComment-1066458 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.