All,
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…
<?php
require_once('../includes/config.php');
require("../includes/common.php");
if(empty($_SESSION['user']))
{
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");
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/style.css">
<link rel="stylesheet" type="text/css" href="../css/pageStyle.css">
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
</head>
<body>
<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>
</form>
</div>
</body>
</html>
I feel like it has something to do with the form action, but any help would be awesome.
Thanks!