Answer the question
In order to leave comments, you need to log in
How to delete from one table and read record in another table in Redbeanphp?
In general, when I try to authorize twice, I get the "no akk" error.
How can I make it so that on the second authorization, the record lookup is already from another table?
require "db.php";
//$token = sha1(uniqid($username, true));
// Переменные с датами
$date = new Datetime();
$date_expire_oneday = new DateTime('+60 minute');
$date_expire_sevendays = new DateTime('+10080 minute');
$date_expire_onemonth = new DateTime('+44640 minute');
// Принимает из HTML формы
$data = $_POST;
if( isset($data['do_login']) )
{
$errors = array();
echo '<pre>';
// Делаем запросы к разным таблицам где лежат определенные ключи
$oneday = R::findOne('oneday', 'login = ?', array($data['login']));
$sevendays = R::findOne('sevendays', 'login = ?', array($data['login']));
$onemonth = R::findOne('onemonth', 'login = ?', array($data['login']));
$hashone = md5($oneday);
$hashseven = md5($sevendays);
$hashmonth = md5($onemonth);
//Здесь заносим ключ авторизации в таблицу "Active"
if($oneday) {
if (password_verify($data['login'], $oneday->password))
$SESSION['logged_user'] = $oneday;
$active = R::dispense('active');
$active -> token = $hashone;
$active ->join_date = $date;
$active ->expire = $date_expire_oneday;
$active -> login = $data['login'];
R::trash($oneday);
$active->token = $hashone;
R::store($active);
}
elseif ($oneday)
{
if( password_verify( $data['login'], $oneday->password ))
$SESSION['logged_user'] = $oneday;
$active = R::dispense('active');
R::store($active); // Сохраняем таблицу
//трансируем на экран
$urll = "http://example.com/activate.php?token=$hashone";
echo $urll;
echo '<div style="color: green;">Ну все ONEDAY </div>';
else
{
$errors[] = 'no akk';
}
}
'</pre>';
if( ! empty($errors) )
{
echo '<div style="color: red;">'.array_shift($errors).'</div><hr>';
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question