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 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据