diff --git a/samples/website_integration/AuthMeController.php b/samples/website_integration/AuthMeController.php index f67cf060..8838bf1d 100644 --- a/samples/website_integration/AuthMeController.php +++ b/samples/website_integration/AuthMeController.php @@ -54,16 +54,18 @@ abstract class AuthMeController { * * @param string $username the username to register * @param string $password the password to associate to the user + * @param string $email the email (may be empty) * @return bool whether or not the registration was successful */ - function register($username, $password) { + function register($username, $password, $email) { + $email = $email ? $email : 'your@email.com'; $mysqli = $this->getAuthmeMySqli(); if ($mysqli !== null) { $hash = $this->hash($password); - $stmt = $mysqli->prepare('INSERT INTO ' . self::AUTHME_TABLE . ' (username, realname, password, ip) ' - . 'VALUES (?, ?, ?, ?)'); + $stmt = $mysqli->prepare('INSERT INTO ' . self::AUTHME_TABLE . ' (username, realname, password, email, ip) ' + . 'VALUES (?, ?, ?, ?, ?)'); $username_low = strtolower($username); - $stmt->bind_param('ssss', $username, $username_low, $hash, $_SERVER['REMOTE_ADDR']); + $stmt->bind_param('sssss', $username, $username_low, $hash, $email, $_SERVER['REMOTE_ADDR']); return $stmt->execute(); } return false; diff --git a/samples/website_integration/index.php b/samples/website_integration/index.php index 0c2a1a1c..c20cbe41 100644 --- a/samples/website_integration/index.php +++ b/samples/website_integration/index.php @@ -22,13 +22,14 @@ $authme_controller = new Sha256(); $action = get_from_post_or_empty('action'); $user = get_from_post_or_empty('username'); $pass = get_from_post_or_empty('password'); +$email = get_from_post_or_empty('email'); $was_successful = false; if ($action && $user && $pass) { if ($action === 'Log in') { $was_successful = process_login($user, $pass, $authme_controller); } else if ($action === 'Register') { - $was_successful = process_register($user, $pass, $authme_controller); + $was_successful = process_register($user, $pass, $email, $authme_controller); } } @@ -39,6 +40,7 @@ into the following form to test it.