当页面操作时,我不希望这段代码运行。
//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>
答案 0 :(得分:4)
更改代码if(!isset($_POST['submit']))
to
if(!isset($_POST['submitarticle']))