KriiV
KriiV

Reputation: 2020

Why is this piece of code running even though I've allowed for that

I do not want this piece of code running when the page actions to itself.

    //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>';
    }

So I've done this:

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>';
  }
}

That doesn't work. It still runs that code after pressing submit!! Here is my form:

            <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>

Upvotes: 0

Views: 58

Answers (1)

Varada
Varada

Reputation: 17052

change the code if(!isset($_POST['submit'])) to if(!isset($_POST['submitarticle']))

Upvotes: 4

Related Questions