douzhang2092 2013-08-25 21:34
浏览 19
已采纳

PHP意外的T_VARIABLE

I'm making a basic lotery script and i'm getting the same error the whole time: Unexpected T_Variable on line 5. Here is my script, I hope someone can help me:

<?php
        $invulcijfer = '';
        if (isset($_POST['sumbitBtn']))
        {
            $invulcijfer = $_POST['cijfer'];
            $pinda = preg_replace("/[^0-9]/", "", $invulcijfer);
            $lotnummer = "1234"; // Hier je 4 cijfers voor lotnummer

            if($invulcijfer = '') {
            echo "<font color='#FF000'>Je moet alles invullen</font>";
        } else if($pinda !== $invulcijfer) {
        echo "<font color='#FF000'>Dat zijn geen cijfers</font>";
        } else {
            if ($pinda == $lotnummer) {
                    echo "<font color='green'>WAUW! Het is je gelukt!</font>";
            } else { 
                    echo "<font color='#FF000'>Sorry, het is niet gelukt..</font>";
                    // Maybe update query van dat ze - points hebben ofso? q wat jij wilt
            }
            }
        }
    }?>
    <br><br>
    <h3>Loterij Script</h3>
    <font color="green">Typ 4 cijfers in en misschien win jij!</font><br><br>

    <form action="" method="post">
        <input type="text" id="naam" name="naam" maxlength="4"/><br>
        <input type="text" id="cijfer" name="cijfer" maxlength="4"/><br>
        <input type="submit" id="submitBtn" name="submitBtn" value="Check je lot"/>
    </form>
  • 写回答

1条回答 默认 最新

  • douyu8187 2013-08-25 21:42
    关注

    EDIT

    I spotted a few errors:

    THIS:

    if (isset($_POST['sumbitBtn']))
    

    it needs to read as

    if (isset($_POST['submitBtn']))
    

    there was a spelling mistake.

    Also if($invulcijfer = '') { needs to be if($invulcijfer == '') {


    You have one closing brace too many.

    Remove the one this one in }?> and your script will work.

    This is the code that I ran, deleting the extra closing brace.

    EDIT #2 (fixed conditions and spelling mistake for submit button.

    <?php
    
    $invulcijfer = '';
      if (isset($_POST['submitBtn']))
      {
    
    $invulcijfer = $_POST['cijfer'];
    $pinda = preg_replace("/[^0-9]/", "", $invulcijfer); 
    $lotnummer = "1234"; // Hier je 4 cijfers voor lotnummer 
    
    if($invulcijfer == '') {
    
        echo "<font color='#FF000'>Je moet alles invullen</font>";
    
    }
    
    elseif  ($pinda !== $invulcijfer){
        echo "<font color='#FF000'>Dat zijn geen cijfers</font>";
    } else {
    
       if ($pinda == $lotnummer) {
    
    echo "<font color='green'>WAUW! Het is je gelukt!</font>";
      }
      else {
    
      echo "<font color='#FF000'>Sorry, het is niet gelukt..</font>";
    
    
     // Maybe update query van dat ze - points hebben ofso? q wat jij wilt
            }
        }
     }
    ?>
    <br><br>
    <h3>Loterij Script</h3>
    <font color="green">Typ 4 cijfers in en misschien win jij!</font><br><br>
    
    <form action="" method="post">
    <input type="text" id="naam" name="naam" maxlength="4"/><br>
    <input type="text" id="cijfer" name="cijfer" maxlength="4"/><br>
    <input type="submit" id="submitBtn" name="submitBtn" value="Check je lot"/>
    </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度