mysql - php login script if returns else even though login info is correct in db -


this block of code login admin backend of page i'm building. parses 'else' statement echoing "incorrect information" statement. saying isn't finding credentials created on server have checked , double checked. confirmed connection script working. i'm stumped. appreciated.

<?php session_start(); if(isset($_session["manager"])) {   header("location: index.php");   exit(); } ?> <?php  // parse log in form if user has filled out , pressed "log in" if (isset($_post["username"]) && isset($_post["password"])) {      $manager = preg_replace('#[^a-za-z0-9]#i', '', $_session["username"]); // filter numbers , letters        $password = preg_replace('#[^a-za-z0-9]#i', '', $_session["password"]); // filter numbers , letters        // connect mysql database       include "../php/connect_to_mysql.php";       $sql = mysql_query("select id admin username='$manager' , password='$password' limit 1"); // query person //------make sure person exists----- $existcount = mysql_num_rows($sql); // count row nums if ($existcount == 1) {     while($row = mysql_fetch_array($sql)){       $id = $row["id"];     }     $_session["id"] = $id;     $_session["manager"] = $manager;     $_session["password"] = $password;     header("location: index.php");     exit();   } else {     echo 'that information incorrect, <a href="index.php">try again</a>.';     exit();   } } ?> 

this form code

<form name="adminform" id="adminform" method="post" action="admin_login.php">               <div class="row collapse">                 <div class="large-2 columns">                   <label class="inline">username</label>                 </div>                 <div class="large-10 columns">                   <input type="text" id="username" placeholder="johndoe" name="username">                 </div>               </div>               <div class="row collapse">                 <div class="large-2 columns">                   <label class="inline">password</label>                 </div>                 <div class="large-10 columns">                   <input type="password" id="password" placeholder="shazam" name="password">                 </div>               </div>               <button type="submit" name="button" id="button" class="radius button">log in</button>         </form> 

the problem may if checking $_post var, when filter use $_session values. try $_post one.

// parse log in form if user has filled out , pressed "log in" if (isset($_post["username"]) && isset($_post["password"])) {     $manager = preg_replace('#[^a-za-z0-9]#i', '', $_post["username"]);     $password = preg_replace('#[^a-za-z0-9]#i', '', $_post["password"]);      // ... 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -