Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: zmc on August 26, 2014, 06:22:32 AM

Title: SMF 2.0.8 Login with e-mail, not username
Post by: zmc on August 26, 2014, 06:22:32 AM
Sorry, I speak a little english.

I would like use login page email address and password combination, not username and password combination for auth. How to?


<?php

require_once(
"forum/SSI.php");
if ($context['user']['is_logged']) {
header ( 'location: http://localhost/forum' ); // logged
} else {
if ( isset ( $_POST [ 'login' ] ) ) {
if ( /* check the $_POST [ 'email' ] and $_POST [ 'pw' ] */ ) {
// login
header ( 'location: http://localhost/forum' );
} else {
print 'error email or/and password fields';
}
}
print '<form method="post" name="login">
      <input type="text" name="email">
      <input type="password" name="pw">
      <input type="submit" name="login">
      </form>'
;
}

?>


My forum is protected/private and I use it is the Settings.php file:


<?php

$ssi_guest_access = true;
Title: Re: SMF 2.0.8 Login with e-mail, not username
Post by: Arantor on August 26, 2014, 06:24:54 AM
This is why you're supposed to be using SMF's own login form because SMF will already accept either quite happily, and this is why you use ssi_login() to do it.