Php 为什么即使我';我已经考虑到了
我不希望这段代码在页面自动运行时运行Php 为什么即使我';我已经考虑到了,php,html,forms,Php,Html,Forms,我不希望这段代码在页面自动运行时运行 //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/javascr
//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>';
}
//有一个相同的id,请求有点真实。(仍然可能是幸运的猜测)
如果($array['isbeingwrited']==1)
{
//这篇文章已经在写了。
echo'alert(“那篇文章正在写。有人抢先到了。你现在将被重定向。”);
echo'window.location.href=“write.php”;
}
所以我做到了:
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>';
}
}
if(!isset($\u POST['submit']))
{
//有一个相同的id,请求有点真实。(仍然可能是幸运的猜测)
如果($array['isbeingwrited']==1)
{
//这篇文章已经在写了。
echo'alert(“那篇文章正在写。有人抢先到了。你现在将被重定向。”);
echo'window.location.href=“write.php”;
}
}
那不行。按submit之后,它仍然运行该代码!!这是我的表格:
<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>
如果(!isset($\u POST['submit']),请更改代码
到
如果(!isset($\u POST['submittarticle']),更改代码if(!isset($\u POST['submit']))
到
如果(!isset($\u POST['submittarticle'])
name=“submittarticle”
您没有名为“submit”的字段,那么它将永远不会被设置。谢谢。我总是搞不清楚是否应该使用id或名称。name=“submitarticle”
您没有名为“submit”的字段,因此它永远不会被设置。谢谢。我总是搞不清楚我是应该用身份证还是名字。。