dongsonghen9931 2016-03-27 14:17
浏览 40
已采纳

将数据库条目转换为大写[重复]

This question already has an answer here:

trying to edit some code for a personal project but having no luck. I want to have the username and password in $shapassword output as all uppercase in the database. Below is the code, specifically looking at this

$shapassword = sha1($username . ":" . $password);

Here is the full code

    public function register($post)
{
    if (!isset($post['username']) || empty($post['username']) || !isset($post['password']) || empty($post['password']) || !isset($post['passwordrep']) || empty($post['passwordrep']) || $post['password'] != $post['passwordrep'] || !isset($post['email']) || empty($post['email'])) {
        die("Unknown error!");
    }
        $username = $this->escape($post['username']);
        $password = $this->escape($post['password']);
        $shapassword = sha1($username . ":" . $password);
        $email = $this->escape($post['email']);
        if (!$this->checkEmail($email)) {die("Error - E-Mail alreadly exists in our database.");}
        if (!$this->checkUsername($username)) {die("Error - Username already exists in our database.");}
        $query = "INSERT INTO " . $this->core->loaded['table'] . " (";
        foreach ($this->core->loaded['fields'] as $field => $value) {
            if ($query == "INSERT INTO " . $this->core->loaded['table'] . " (") {
                $query = $query . "`" . $field . "`";
            } else {
                $query = $query . ", `" . $field . "`";
            }
        }
        $query = $query . ") VALUES (";
        $qe = $query;
        foreach ($this->core->loaded['fields'] as $field => $value) {
            if ($query == $qe) {
                $query = $query . "'" . $this->format($username, $password, $shapassword, $email, $value) . "'";
            } else {
                $query = $query . ", '" . $this->format($username, $password, $shapassword, $email, $value) . "'";
            }
        }
        $query = $query . ");";
        $this->DBC->query($query);

        if ($this->DBC->errno) {die($this->DBC->error);} else {die("true");}
        if ($this->config->email_notification) {
            $subject = $this->format($username, $password, $shapassword, $email, $this->config->email_subject);
            $text = $this->format($username, $password, $shapassword, $email, $this->config->email_text);
            $headers = "From :" . $this->config->email_email;
            mail($email, $submit, $text, $headers);
        }
   }
}

I'm fairly certain this is a simple fix, but I haven't been able to get it to work. If you could help that would be great, thanks.

</div>
  • 写回答

1条回答 默认 最新

  • duannai1883 2016-03-27 14:26
    关注

    try string strtoupper ( string $string )

    Example:

    <?php
    $str = "Mary Had A Little Lamb and She LOVED It So";
    $str = strtoupper($str);
    echo $str; // Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题
  • ¥15 有没有人能解决下这个问题吗,本人不会编程
  • ¥15 plotBAPC画图出错
  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥20 能提供一下思路或者代码吗