Otp 不在数据库中 post
Otp is not post in database
用户提交邮件 ID 后,otp 将发送到该电子邮件 ID,但我的代码无法正常工作 post 数据库中的电子邮件 ID,但不是 otp。请问有人可以帮忙吗?
控制器代码auth.php
public function register()
{
$alphabet = '1234567890';
$otp = array(); //remember to declare $pass as an array
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $alphaLength);
$otp[] = $alphabet[$n];
}
$newotp = implode($otp);
// $data['otp'] = $newotp;
$to = $this->input->post('email');
$subject = "OTP FOR LOGIN";
$message = '
Dear, User ,<br> <br>
Thanks You For Requesting OTP.<br><br>
Your Username is - ' . $to . ' And <br><br>
Your Password Is - <b>' . $newotp . '</b> <br><br>
Thank you!<br><br>
This is an autogenerated email. Please do not reply to this email.
<br><br>
';
$mail = $this->Others->send_email($to, $subject, $message);
$data = $this->user_model->insert('cred', ['email' => $to], ['otp' => ($newotp)]);
redirect(base_url() . 'auth/login');
}
型号代码user_model.php
public function insert($table, $data = array())
{
$this->db->insert('cred', $data);
$afftectedRows = $this->db->affected_rows();
if ($afftectedRows == 1) {
$id = $this->db->insert_id();
return $id;
} else {
return FALSE;
}
}
在您的控制器中,您实际上将三个参数传递给 $this->user_model->insert()
而不是两个。第二个参数需要是一个数组。
尝试更新以下行:
$data = $this->user_model->insert('cred', ['email' => $to, 'otp' => $newotp]);
用户提交邮件 ID 后,otp 将发送到该电子邮件 ID,但我的代码无法正常工作 post 数据库中的电子邮件 ID,但不是 otp。请问有人可以帮忙吗?
控制器代码auth.php
public function register()
{
$alphabet = '1234567890';
$otp = array(); //remember to declare $pass as an array
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $alphaLength);
$otp[] = $alphabet[$n];
}
$newotp = implode($otp);
// $data['otp'] = $newotp;
$to = $this->input->post('email');
$subject = "OTP FOR LOGIN";
$message = '
Dear, User ,<br> <br>
Thanks You For Requesting OTP.<br><br>
Your Username is - ' . $to . ' And <br><br>
Your Password Is - <b>' . $newotp . '</b> <br><br>
Thank you!<br><br>
This is an autogenerated email. Please do not reply to this email.
<br><br>
';
$mail = $this->Others->send_email($to, $subject, $message);
$data = $this->user_model->insert('cred', ['email' => $to], ['otp' => ($newotp)]);
redirect(base_url() . 'auth/login');
}
型号代码user_model.php
public function insert($table, $data = array())
{
$this->db->insert('cred', $data);
$afftectedRows = $this->db->affected_rows();
if ($afftectedRows == 1) {
$id = $this->db->insert_id();
return $id;
} else {
return FALSE;
}
}
在您的控制器中,您实际上将三个参数传递给 $this->user_model->insert()
而不是两个。第二个参数需要是一个数组。
尝试更新以下行:
$data = $this->user_model->insert('cred', ['email' => $to, 'otp' => $newotp]);