Page Refreshes Instead of Adding


I am working on an application that will keep track of documentation for us.

The following code is the page I use to add a set of documentation to my application. In my mainframe, I have two div’s - the navigation DIV and the content div. When someone clicks on the link for the following page, it opens in the content div. When you fill out the information, it just refreshes, and opens the page in a new tab. Not sure how to fix it…

        header("Location: ../index.php");
        die("Redirecting to index.php");

if(isset($_POST['submit'])) {
$hostname = $_POST['hostname'];
$ip = $_POST['ip'];
$port = $_POST['port'];
$notes = $_POST['notes'];

$query = "INSERT INTO ip (id, hostname, ip, switchport, notes) VALUES ('NULL', '$hostname', '$ip', '$port', '$notes')";

$result = mysql_query($query) or die ("You've got an error " . mysql_error() . " in query $query");

    <link rel="stylesheet" type="text/css" href="../css/style.css">
	    <link rel="stylesheet" type="text/css" href="../css/pageStyle.css">
  <script src="//"></script>

 <div class="login">
    <h1>Add IP Documentation</h1>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
	  <p><input type="text" name="hostname" value="" placeholder="Hostname"></p>
	  <p><input type="text" name="ip" value="" placeholder="IP Address"></p>
	  <p><input type="text" name="ports" value="" placeholder="Switch Port"></p>
	  <p><input type="text" name="notes" value="" placeholder="Notes"></p>
	  <p class="submit"><input type="submit" name="commit" value="Add IP Doc"></p>


I feel like it has something to do with the form action, but any help would be awesome.


I can’t say it’s the problem, but I notice you have “port” and “ports”.
Also, unless it’s changed, don’t you need a session_start() first thing?