lundi 7 décembre 2015

Authenticating user login with PHP from Sqlite database

My partner and I have been up for nearly 24 hours straight trying to figure this out, and I feel like it's something so simple that we shouldn't have an issue. We are trying to authenticate users using PHP from an sqlite database. We've seen countless posts and tutorials on how to do this with a mySQL database, but not sqlite3. The one we did find was on here and it did not work for us (and no, we are not just copying and pasting). So, can anyone tell us what is going wrong? We keep getting a server 500 error and its not validating at all. At first,the php would display on the page, but now we just get errors. In short -- we are trying to pull email address and password information from a sqlite database and validate it with php, so the user can login and see the member homepage. PHP CODE:

    <?php
$dir = 'sqlite:db/Quizionality.db':
 $db = new PDO($dir) or die ("Unable to open");


 $email_address = $_POST['email_address'];
 $password = $_POST['password'];

 $email_address =($email_address);
 $password =($password);

 $email_address = intval($_POST["email_address"]);
 $password = intval($_POST["password"]);
 $sql = "SELECT * FROM user_info WHERE email_address='$email_address' AND password='$password'";
 $sql .= "where email_address=? AND where password=?";

 $stmt = $db->prepare($sql);
 $stmt->bindParam(1, $email_address);
 $stmt->bindParam(2, $password);
 $result = $stmt->execute($sql);

 while($column=$stmt->fetch())
 {
     echo $column["email_address"];
     echo $column["password"];
 };
  };


 if($email_address==1){
     echo "<h1>Logged In</h1>";
 };

?>

HTML

<!DOCTYPE html> 
<html>
  <head>
    <title>Quizonality</title>

    <link rel="stylesheet" href="css/QuizonalityLogInForMembers.css" type="text/css" />
  </head>
  <body>
    <header>
      <nav id="header_wrapper">
        <h1 id="logo"><a href="#"> QUIZONALITY</a></h1>
        <ul id="navigate">
          <li><a href="#">Home</a></li>
          <li><a href="#">Contact</a></li>
          <li><a href="#">Login</a></li>
          <li><a href="#">Create</a></li>
        </ul>
      </nav>
    </header>


<body>

<div id="main">


<h2 id="main_head"> Already Existing Members </h2>

<form id="loginform" name="myForm" method="post" action="login_for_mems.php">

<div>Username (Email):</div>
<input  id="username" type="text" name="username"  >


<div>Password:</div>
<input id="password" type="text" name="password" type="password">

<br>
<input type="submit" value="Login" >
</br>

</div>

</form>




 <footer>
   <div id="footer_nav">
    <div id="footer_nav_wrapper">

     <ul>
      <li><a href="#">Home</a></li>
      <li><a href="#">Contact</a></li>
      <li><a href="#">Login</a></li>
      <li><a href="#">Create</a></li>
     </ul>



  </footer>
 </body>
</html>

Thanks for any suggestions in advance.

Aucun commentaire:

Enregistrer un commentaire