推荐动机

时间:2018-09-07 20:06:14

标签: php mysql

我对php和mysql很陌生。我在索引中添加了注册字段“引荐”。我添加它是我想到的最简单的方法,就是在播放器表中添加引用行。当用户在注册期间输入引荐时,它将被存储到数据库中,而无需检查新用户输入的用户名是否有效。

if (isset($_POST['register'])) {
    $username = $_POST['username'];
    $password = hash('sha256', $_POST['password']);
    $email    = $_POST['email'];
    $ref      = $_POST['ref'];
    $sql = mysqli_query($connect, "SELECT username FROM `players` WHERE username='$username'");
    if (mysqli_num_rows($sql) > 0) {
        echo '<br /><div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' . lang_key("username_taken") . '</div>';
    } else {
        $sql2 = mysqli_query($connect, "SELECT email FROM `players` WHERE email='$email'");
        if (mysqli_num_rows($sql2) > 0) {
            echo '<br /><div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i>  ' . lang_key("email_taken") . '</div>';
        } else {
            $money    = $row['startmoney'];
            $gold     = $row['startgold'];
            $themeid  = $rowtd['id'];
            $langcode = $rowld['langcode'];
            
            $insert = mysqli_query($connect, "INSERT INTO `players` (username, password, email, ref, money, gold, theme, language) VALUES ('$username', '$password', '$email', '$ref', '$money', '$gold', '$themeid', '$langcode')");

今天,我希望在介绍人时给予激励。所以我一直在分解我要做的方法。我想出了类似的东西。

 $sql3 = mysqli_query($connect, "SELECT ref FROM `players` WHERE ref='$ref'");
    if (mysqli_num_rows($sql3) > 0) {
        echo $player_update = mysqli_query($connect, "UPDATE `players` SET money=money+'5000' WHERE ref='$ref'");';
   }else{

这是行不通的,我不确定这是我应该怎么做。.我是一个初学者,了解了所有我自己的知识,因此将非常感谢小费,感谢任何阅读/帮助的人!

0 个答案:

没有答案