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;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!