Location: PHPKode > projects > XMasDB > xmasdb/new.php
<?php
// start the session
session_start();

// is the one accessing this page logged in or not?
if (!isset($_SESSION['basic_is_logged_in']) 
    || $_SESSION['basic_is_logged_in'] !== true) {

    // not logged in, move to login page
    header('Location: index.php');
    exit;
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>X-Mas Gift Database</title>
<style type="text/css">@import url("style.css");</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<h2>X-Mas Gift Database</h2>
<br>

<?
if(isset($_POST['add']))
{
include 'config.php';
include 'lib/opendb.php';

$name = $_POST['name'];
$gift = $_POST['gift'];
$got = $_POST['got'];

$query = "INSERT INTO gifts (name, gift, got) VALUES ('$name', '$gift', '$got')";
mysql_query($query) or die('Error, insert query failed');

$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, insert query failed');

include 'lib/closedb.php';

echo "<h3>New Gift Added Successfully!</h3><BR>
<p align='center'><input type=\"button\" class=\"btn\" onClick=\"window.location='list.php'\" value=\"Gift List\"> &nbsp; &nbsp;
<input type=\"button\" class=\"btn\" onClick=\"window.location='new.php'\" value=\"Add Another Gift\"></p>";
}
else
{
?>


<form method="post" name="add" action="">
<p align="center">
<table width="400" border="0" cellspacing="0" cellpadding="3">
<tr> 
<td width="250">Name</td>
<td><input name="name" size="35" type="text" id="name"></td>
</tr>
<tr> 
<td width="250">Gift</td>
<td><input name="gift" size="35" type="text" id="gift"></td>
</tr>
<td width="200">Got It?</td>
<td><select name="got"><option value ="Yes">Yes</option><option value ="No">No</option></select></td>
</tr>
</table><br>

<p align="center"><input type="button" class="btn" onClick="window.location='list.php'" value="Back"> &nbsp;&nbsp; <input class="btn" name="add" type="submit" id="add" value="Add New Gift"></p>

</form>

<?
}
?>
</body>
</html>

Return current item: XMasDB