I am trying to construct a cms for a school project. I am in the early stages of the project and I am creating dynamic forms using PHP. The following code has four different forms in it and depending on which form is requested, the respective form populates. My problem is that now that I got my file to compile, the last form shows up in addition to the requested form. I am using “if” statements and I am wondering if the last form should utilize another type of flow statement. Any suggestions?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Robert Izzo's Final Project</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="http://cdlwebsysdev.esc-atsystems.net/rizzo/externalcss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
//begin main if statement get from form selector
if(isset($_GET["form"]))
{
//begin if statement for soap form
if($_GET["form"]=="productentrysoap")
{
?>
<?php
//begin php code for form validation of soap form
$soapcatalog = $_POST["soapcatalog"];
$soapdescription = $_POST["soapdescription"];
$soapprice = $_POST["soapprice"];
$soapunits = $_POST["soapunits"];
$uploadField = $_POST["uploadField"];
$tried=$_POST['tried']="yes";
//begin if statement $tried
if ($tried=="yes"){
$validated=(!empty($soapcatalog) && !empty($soapdescription) && !empty($soapprice) && !empty($soapunits) && !empty($uploadField));
//begin if statement $validated
if (!$validated){
?>
<p>
Please enter the catalog number, description, price, units and upload fields. All forms must be completed to continue.
</p>
<?php
//end if $validated
}
//end if $tried
}
//begin if statement for $tried and $validated validation
if (($tried) && ($validated)) {
echo "<p>The item has been created.</p>";
//end if statement for $tried and $validated validation
}
?>
<form action="http://cdlwebsysdev.esc-atsystems.net/rizzo/soapprocessing.php" method="post">
<fieldset id="soapproduct_entry"><legend>Soap Product Entry</legend>
<table>
<tr>
<td><label for="soapcatalog"> Catalog: </label><input type="text" name="soapcatalog" id="soapcatalog" /></td>
</tr>
<tr>
<td><label for="soapdescription"> Soap Description: </label><input type="text" name="soapdescription" id="soapdescription" /></td>
</tr>
<tr>
<td><label for="soapprice">Price: </label><input type="text" name="soapprice" id="soapprice" /></td>
</tr>
<tr>
<td><label for="soapunits">total number of units: </label><input type="text" name="soapunits" id="soapunits" /></td>
</tr>
</table>
<label>Upload Photo: <input type="file" name="uploadField" />
</label>
<input type="submit" value="click to submit" /> <input type="reset"/>
</fieldset>
</form>
<?php
//end if for soap form
}
}
?>
<?php
////////////////////jewelry code//////////////////////////////////
//begin elseif statement for jewelry form
if ($_GET["form"]=="productentryjewelry"){
?>
<?php
// begin php code for jewelry form validation
$jewelrycatalog = $_POST["jewelrycatalog"];
$jewelrydescription = $_POST["jewelrydescription"];
$jewelryprice = $_POST["jewelryprice"];
$jewelryunits = $_POST["jewelryunits"];
$uploadField = $_POST["uploadField"];
$tried=$_POST["tried"]="yes";
//begin if statement $tried
if ($tried=="yes"){
$validated=(!empty($jewelrycatalog) && !empty($jewelrydescription) && !empty($jewelryprice) && !empty($jewelryunits) && !empty($uploadField));
//begin if statement $validated
if (!$validated){
?>
<p>
The catalog number, description, price, units and upload fields need to be completed. Please complete to continue.
</p>
<?php
// end if statement $validated
}
//end if statement $tried
}
//begin if statement $tried and $validated validation
if (($tried) && ($validated)) {
echo "The item has been created.";
//end if statement $tried and $validated validation
}
?>
<form action="http://cdlwebsysdev.esc-atsystems.net/rizzo/jewelryprocessing.php" method="post">
<fieldset id="jewelryproduct_entry"><legend>Jewelry Product Entry</legend>
<table>
<tr>
<td><label for="jewelrycatalog"> Catalog: </label><input type="text" name="jewelrycatalog" id="jewelrycatalog" /></td>
</tr>
<tr>
<td><label for="jewelrydescription"> Jewelry Description: </label><input type="text" name="jewelrydescription" id="jewelrydescription" /></td>
</tr>
<tr>
<td><label for="jewelryprice">Price: </label><input type="text" name="jewelryprice" id="jewelryprice" /></td>
</tr>
<tr>
<td><label for="jewelryunits">total number of units: </label><input type="text" name="jewelryunits" id="jewelryunits" /></td>
</tr>
</table>
<label>Upload Photo: <input type="file" name="uploadField" />
</label>
<input type="submit" value="click to submit" /> <input type="reset"/>
</fieldset>
</form>
<?php
//end if for jewlery form
}
//?>
<?php
///////////////// craft code ////////////////////////////////////////
if ($_GET["form"]=="productentrycraft"){
?>
<?php
$craftcatalog = $_POST["craftcatalog"];
$craftdescription = $_POST["craftdescription"];
$craftprice = $_POST["craftprice"];
$craftunits = $_POST["craftunits"];
$uploadField = $_POST["uploadField"];
$tried=$_POST['tried']="yes";
if ($tried=="yes"){
$validated=(!empty($craftcatalog) && !empty($craftdescription) && !empty($craftprice) && !empty($craftunits) && !empty($uploadField));
if (!$validated){
?>
<p>
The catalog number, description, price, units and upload fields need to be completed. Please complete to continue.
</p>
<?php
}
if (($tried) && ($validated)) {
echo "<p>The item has been created.</p>";
}
?>
<form action="http://cdlwebsysdev.esc-atsystems.net/rizzo/craftprocessing.php" method="post">
<fieldset id="craftproduct_entry"><legend>Craft Product Entry</legend>
<table>
<tr>
<td><label for="craftcatalog"> Catalog: </label><input type="text" name="craftcatalog" id="craftcatalog" /></td>
</tr>
<tr>
<td><label for="craftdescription"> Craft Description: </label><input type="text" name="craftdescription" id="craftdescription" /></td>
</tr>
<tr>
<td><label for="craftprice">Price: </label><input type="text" name="craftprice" id="craftprice" /></td>
</tr>
<tr>
<td><label for="craftunits">total number of units: </label><input type="text" name="craftunits" id="craftunits" /></td>
</tr>
</table>
<label>Upload Photo: <input type="file" name="uploadField" />
</label>
<input type="submit" value="click to submit" /> <input type="reset"/>
</fieldset>
</form>
<?php
//end if for craft form
}
}
//?>
<?php
////////////////////Nick Update//////////////////////////////////////
if ($_GET["form"]=="nickupdates")
?>
<?php
$Nickupdate= $_POST["Nickupdate"];
$uploadField = $_POST["uploadField"];
$tried=$_POST["tried"]="yes";
if ($tried=="yes"){
$validated=(!empty($Nickupdate) && !empty($uploadField));
if (!$validated){
?>
<p>
The Nick update field the file upload fields need to be completed. Please complete to continue.
</p>
<?php
if (($tried) && ($validated)) {
echo "<p>The item has been created.</p>";
}
?>
<form action="http://cdlwebsysdev.esc-atsystems.net/rizzo/nickupdates.php" method="post">
<fieldset><legend>Nick Update:</legend>
<label> Update:<br />
<textarea name="Nickupdate" id="Nickupdate" cols="40" rows="2">Enter update here</textarea>
</label><br /><br />
<label>Upload Photo: <input type="file" name="uploadField" />
</label>
<input type="submit" value="click to submit" /> <input type="reset" />
</fieldset>
</form>
<?php
//end if for Nickupdate form
}
}
?>
</body>
</html>