Adding to the database on one page

Good afternoon.
Please tell me how to add to the database using just one page. To have a page to be displayed content, the bottom form was adding records. After you add automatically redesigned to the page with the records

if($_GET['action'] == 'add')
{
       if($_POST['do'] =='')
       {
        echo
        '
        <form action="?action=add" method="post" class="niceform">
        <fieldset>
        <dl>
            <dt><label>IP:</label></dt>
            <dd><input type="text" name="ip" id="" size="30 " /></dd>
        </dl>
        <dl class="submit">
            <input type="submit" name="do" id="submit" value="" />
        </dl>
        </fieldset>
        </form>
        ';
       }
       else
       {
          $result = mysql_query("INSERT INTO equipment VALUES(".$_POST['ip'].")");
          if($result)
          {
              @header('../');
              echo
              '
                . <a href="?action=view_news"></a>   .
              ';
          }
          else
          {
              echo
                '
                <div class="error_box">
                      .
                </div>  
                ';
          }
       }
}

Answer 1, Authority 100%

For example, so:

do.php

if(isset($_GET['action'])) {
    if($_GET['action'] == 'add') {
        if(!isset($_POST['do'])) {
            echo
            '
        <form action="do.php?action=add" method="post" class="niceform">
            <fieldset>
        <dl>
        <dt><label>IP:</label></dt>
        <dd><input type="text" name="ip" id="" size="30 " /></dd>
        </dl>
        <dl class="submit">
        <input type="submit" name="do" id="submit" value="" />
        </dl>
        </fieldset>
        </form>
        ';
        } else {
            $result = mysql_query("INSERT INTO equipment VALUES('".mysql_real_escape_string($_POST['ip'])."')");
            if($result) {
                header("Location: do.php?action=view_news"); // 
                ...
            } else {
                die(mysql_error());
            }
        }
    }
}