mercredi 30 décembre 2015

Php/Mysql login authentication

I am unable to authenticate using Php/mysql, using the following method. I used a form in order to login. Please check the following and help me out?

      //form.php


       <html>
       <body>
        <h2>Authentication</h2> 
        <form action="login.php" method="post">
        <label>Userid :</label>
       <input type="text" id="userid" name="userid" >
         <label>Password :</label>
        <input type="password" id="password" name="password">
      <input name="submit" type="submit" value=" Login ">
       <span><?php echo $error; ?></span>
      </form>
       </body>
       </html>



       //login.php

        <?php
        $message="";
          if(count($_POST)>0) 
             {
           mysql_connect("localhost", "root", "kami123")or
            die(mysql_error());    
           mysql_select_db("ccmsdb") or die(mysql_error());



           $result = mysql_query("SELECT *FROM client WHERE 
           userid='" . $_POST["userid"] . "' AND 
           password = '". $_POST["password"]."'");



           $count  = mysql_num_rows($result);
           if($count==0) {
            $message = "Invalid Username or Password!";
           } else 
              {
           $message = "You are successfully authenticated!";
             }
                }
                 ?>




Aucun commentaire:

Enregistrer un commentaire