Last form showing up in all previous forms.

For general web development questions that are not specifically related to CSS HTML Validator. This includes (but is not limited to) general HTML, CSS, Accessibility, JavaScript, and SEO questions.
Post Reply
rjizzo
Rank 0 - Newcomer
Posts: 5
Joined: Thu Apr 10, 2014 1:33 pm

Last form showing up in all previous forms.

Post by rjizzo »

Can you explain to me why the last form of this combination XHTML and PHP code populates every other form. I tried to segment the codes (Soap, jewelry, craft and Nick update) with long comment lines for easier understanding of my organization. Ideally, I would like one form at a time. Not sure if it has anything to do with all the "If "statements. Any help would be greatly appreciated.

Code: Select all

<!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  soap code///////////////////////////////////////
   $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:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="uploadField" />
 </label>
 <input type="submit" value="click to submit" />&nbsp;<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:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="uploadField" />
 </label>
 <input type="submit" value="click to submit" />&nbsp;<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:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="uploadField" />
 </label>
 <input type="submit" value="click to submit" />&nbsp;<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:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="uploadField" />
 </label>
 <input type="submit" value="click to submit" />&nbsp;<input type="reset" />
 </fieldset>
 </form>
<?php 


//end if for Nickupdate form
}
}

?>


</body>
</html>





User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Last form showing up in all previous forms.

Post by Albert Wiersch »

Can you post a link to a live example so I can see the source as well as the latest version of the code (if you've since updated it)?
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
rjizzo
Rank 0 - Newcomer
Posts: 5
Joined: Thu Apr 10, 2014 1:33 pm

Re: Last form showing up in all previous forms.

Post by rjizzo »

http://cdlwebsysdev.esc-atsystems.net/rizzo/formselectionfinalproject.html

This will bring you to the form selector. When you select one of the forms, you get that form, but also the last form called "Nick Update"
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Last form showing up in all previous forms.

Post by Albert Wiersch »

Thanks... from a quick inspection it looks like you may be missing a left curly brace after:

Code: Select all

if ($_GET["form"]=="nickupdates")
Thus that if statement controls only one line and not a block of code.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
Post Reply