Sindbad~EG File Manager
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php
require_once("DB.php");
require_once("query.php");
$state = $_GET['state'];
?>
<html>
<head>
<title>Exercise One</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if($state == "insert")
{ // insert a new record, but don't show the new-record form
$Last = $_POST['Last'];
$First = $_POST['First'];
$Email = $_POST['Email'];
$Design = $_POST['Design'];
$sql = "INSERT INTO ClassList (LastName, FirstName, Email, Design) VALUES ('$Last', '$First', '$Email', '$Design');";
Query($sql);
?>
<FORM action ="<?php echo $_SERVER['PHP_SELF']?>"
<p><INPUT id="ShowTheForm" type="submit" value="Add a New Record" name="ShowTheForm"></P>
</FORM>
<?php
}
else
{ // show the form
?>
Use the following form to add a new record to the database:
<FORM action="<?php echo $_SERVER['PHP_SELF'] . "?state=insert";
?>" method="POST">
<table BORDER="0" CELLSPACING="1" CELLPADDING="1">
<?php
for($i=0;$i<4;$i++)
{ if($i==0) $Name = 'Last';
else if ($i==1) $Name = 'First';
else if($i==2) $Name = 'Email';
else if($i==3) $Name = 'Design';
echo "<tr>";
echo "<td>$Name</td>";
echo "<td><input type=\"text\" id=\"$Name\" name=\"$Name\" value=\"\"></td></tr>";
}
?>
</table>
<p>
<INPUT id="SubmitNewRecord" type="submit" value="Submit" name="SubmitNewRecord"></P>
</form>
</p>
<?php } ?>
<p> Here are the contents of table ClassList: </p>
<table border="1" >
<tr>
<td>Last Name</td>
<td>First Name</td>
<td>Email </td>
<td>Design Group</td>
</tr>
<?php
$sql = "SELECT LastName, FirstName, Email, Design FROM ClassList;";
$q = Query($sql);
while($q->fetchInto($row))
{ echo "<tr>";
for($i = 0; $i< 4; $i++)
{ echo "<td>" . $row[$i] . "</td>";
}
echo "</tr>";
}
?>
</table>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists