0

我不希望当页面对其自身进行操作时运行这段代码。

    //There was an identical id and request is somewhat real. (Still possible of a lucky guess)
    if($array['isbeingwritten'] == 1)
    {
        //The article is already being written.
        echo '<script type="text/javascript">alert("That article is being written. Someone beat you to it. You will now be redirected.");</script>';
        echo '<script type="text/javascript">window.location.href="write.php";</script>';
    }

所以我这样做了:

if(!isset($_POST['submit']))
{
  //There was an identical id and request is somewhat real. (Still possible of a lucky guess)
  if($array['isbeingwritten'] == 1)
  {
        //The article is already being written.
    echo '<script type="text/javascript">alert("That article is being written. Someone beat you to it. You will now be redirected.");</script>';
    echo '<script type="text/javascript">window.location.href="write.php";</script>';
  }
}

那是行不通的。按下提交后它仍然运行该代码!这是我的表格:

            <form method="post" id="writearticle" action=""> 
                <textarea rows="30" cols="85" id="articlecontent" name="content" placeholder="Write the article here. Try to abide by the instructions and keywords provided." onkeyup="checkWordCount();" ></textarea>
                <br />      
                <input type="submit" id="submit" name="submitarticle" value="Submit Article" class="submit" disabled />     

                <br /><br /><br /><br /><br />
            </form>
4

1 回答 1

4

更改代码if(!isset($_POST['submit'])) to if(!isset($_POST['submitarticle']))

于 2012-10-06T06:35:58.617 回答