gpt4 book ai didi

php - 如何通过同一个帖子检查电子邮件地址或用户名是否有效或是否存在?

转载 作者:行者123 更新时间:2023-11-29 11:14:14 25 4
gpt4 key购买 nike

如何通过同一个帖子检查电子邮件地址或用户名是否有效或是否存在?

HTML

 <form action="/index" method="post">
<input name="post" type="text" value="Username or Email" />
<input name="submit" name="send" value="Submit" />
</form>

PHP

  public function index($post) 
{
$results = $this->db->where('username', $post)
->where('email', $post)
->get('users');

if($results->num_rows() > 0)
{
//The user has an email or username
echo "valid";
} else {
echo "Invalid";
}
}

最佳答案

将第二个 ->where 子句更改为 ->or_where

public function index($post) 
{
$results = $this->db->where('username', $post)
->or_where('email', $post)
->get('users');

if($results->num_rows() > 0)
{
//The user has an email or username
echo "valid";
} else {
echo "Invalid";
}
}

查看此文档以供引用 Active Record : CodeIgniter

关于php - 如何通过同一个帖子检查电子邮件地址或用户名是否有效或是否存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40008992/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com