duan1983 2018-03-25 06:56
浏览 44
已采纳

带有check [php]的php mysql输入脚本

This question already has an answer here:

ive a problem with my input script. the check grind are broken and dont work right now.

The Script should look for the get over and should check it with db support.

In my case, the while grind are buggy.... they dont work right....

<?php


    date_default_timezone_set('Europe/Berlin');

    $mysqli = new MySQLi("localhost", "dbuser", "dbpass", "clantools");
    if ($mysqli->connect_errno) {
        echo "Failed to connect to MySQL: ({$mysqli->connect_errno}) {$mysqli->connect_error}";
    }

    $result = mysqli_query($mysqli,"SELECT * FROM clanmember_ra1se where '".$_GET['account_name']."' = Playername");

    //while($row = mysqli_fetch_array($result))
    //  {
    //
    //      if ($_GET['clantag'] = $row['Clantag']) {

    if (mysqli_num_rows($result) != 0)
    {


            echo '
            <!DOCTYPE html>
            <html>
            <head>
            <title>Code Eingabe</title>
            </head>
            <body>
            <form action="?" method="get">
              <input type="hidden" name="account_name" value="'.$_GET['account_name'].'">
              <input type="hidden" name="clantag" value="'.$_GET['clantag'].'">
              <input type="hidden" name="role" value="'.$_GET['role'].'">
              <input type="hidden" name="role_i18n" value="'.$_GET['role_i18n'].'">
              <p>Code: <input type="text" name="code" /></p>
              <p><input type="radio" name="activity" id="leitend" value="leitend" />Leitender FK</p>
              <p><input type="radio" name="activity" id="gespielt" value="gespielt" />Gespielt</p>
              <p><input type="radio" name="activity" id="bereit" value="bereit" />Bereit</p>
              <p><input type="submit" name="absenden" value="Code senden"/></p>
            </form>

            </body>
            </html>
            ';

            if ( empty ($_GET['code']) != TRUE and isset($_GET['absenden']))
                {
                    // wenn beide Bedingungen zutreffen, 
                    // dann folgende Anweisungen ausführen

                    if (isset ($_GET['activity'])){
                         if ($_GET['activity']=="leitend"){
                              $status = 'leitend';
                         }
                         if ($_GET['activity']=="gespielt"){
                              $status = 'gespielt';
                         }
                         if ($_GET['activity']=="bereit"){
                              $status = 'bereit';
                         }
                    }
                    $eingabe = date("Y-m-d H:i:s", time());


                    //$mysqli = new MySQLi("localhost", "dbuser", "dbpass", "clantools");
                    //if ($mysqli->connect_errno) {
                    //      echo "Failed to connect to MySQL: ({$mysqli->connect_errno}) {$mysqli->connect_error}";
                    //}

                    $result_code = mysqli_query($mysqli,"SELECT * FROM code_ra1se where '".$_GET['code']."' = code");



                    if (mysqli_num_rows($result_code) != 0)
                        {
                            echo '<br>';
                            echo '<center>Code wird gepr&uuml;ft</center>';
                            echo "<br>";
                            echo "<br>";
                            echo "<br>";
                            echo "<br>"; 

                        while($row = mysqli_fetch_array($result_code))
                         {


                            $result = mysqli_query($mysqli,"SELECT * FROM eingabe_code_ra1se where '".$_GET['account_name']."' = spielername");

                            while($row = mysqli_fetch_array($result))
                                {

                                    if ($_GET['code'] != $row['code'] {





                                    //echo ''.$row['gueltigkeit'].' > '.$eingabe.''; 

                                    if ($row_code['gueltigkeit'] > $eingabe){



                                        $sql = "INSERT INTO eingabe_code_ra1se (spielername,code,clantag,eingabezeit,role,role_i18n,activity ) VALUES ('".$_GET['account_name']."', '".$_GET['code']."', '".$_GET['clantag']."', '".$eingabe."', '".$_GET['role']."', '".$_GET['role_i18n']."', '".$status."')";

                                        if ($mysqli->query($sql) == TRUE) {
                                                echo "<b><center>Code erfolgreich &uuml;bermittelt!</center><br> BITTE SEITE SCHLIE&szlig;EN!!</b> <br>";
                                        } else {
                                                echo "Error: " . $sql . "<br>" . $mysqli->error;
                                        }

                                        $mysqli->close();

                                        } else {


                                            echo "<b><center>Code ist nicht g&uuml;ltig!</center></b> <br>";

                                        }

                                    } else {

                                            echo "<b><center>Du hast den Code breits eingegeben!</center></b> <br>";

                                    }

                                }

                            }
                            }  else {

                                    echo "<b><center>Der Code existiert nicht!</center></b> <br>";

                            }
                }
        } else {

            echo "<b><center>Du bist nicht berechtigt den Code hier einzugeben!</center></b> <br>";

        }

?>

The problem of this scripts are the while grind. how can i make this easier? i think the most of the while grind are usless.....

</div>
  • 写回答

1条回答 默认 最新

  • dtn55928 2018-03-25 07:48
    关注

    Replace the line,

    if ($_GET['code'] != $row['code'] { 
    

    with this,

    if ($_GET['code'] != $row['code']) {
    

    You have forgotten to close the if statement.

    if (condition) {
        code to be executed if condition is true;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集