auth_adodb_example.php 751 B

12345678910111213141516171819202122232425
  1. <?php
  2. // NOTE: The ADOdb and PEAR directories MUST be in your PHP include_path!
  3. require_once "Auth/Auth.php";
  4. function loginFunction() {
  5. ?>
  6. <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  7. <input type="text" name="username">
  8. <input type="password" name="password">
  9. <input type="submit">
  10. </form>
  11. <?php
  12. }
  13. $dsn = 'mysql://username:password@hostname/database';
  14. // To use encrypted passwords, change cryptType to 'md5'
  15. $params = array('dsn' => $dsn, 'table' => 'auth', 'cryptType' => 'none',
  16. 'usernamecol' => 'username', 'passwordcol' => 'password');
  17. $a = new Auth("ADOdb", $params, "loginFunction");
  18. $a->start();
  19. if ($a->getAuth()) {
  20. echo "Success";
  21. // * The output of your site goes here.
  22. }