将数据库条目转换为大写

时间:2016-03-27 14:17:09

标签: php mysql

尝试编辑个人项目的某些代码,但没有运气。我想在$ shapassword输出中使用用户名和密码作为数据库中的全部大写。下面是代码,特别是看这个

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

这是完整的代码

    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);
        }
   }
}

我相当确定这是一个简单的修复,但我无法让它工作。如果你能提供帮助那就太棒了,谢谢。

1 个答案:

答案 0 :(得分:0)

尝试string strtoupper ( string $string )

示例:

<?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
?>