Passing variables with Post & if elseif statements
Posted: Sat May 27, 2006 12:03 pm
I created a form where user could provide info for a notice to be posted on local cable TV community channel. When the form is completed the Submit button posted the variables to a page where all user input was shown for the user to verify. When it first was uploaded, the user could use the back button to make any changes. Now the back button takes you to a blank form.
Any suggestions how to keep the PHP variables in the form when the back button is used?
Here is a small portion of the info.php file
here's a small portion of the confirm.php file
Another issue occurs because I created an edit form that the confirm.php file posts to. If you make a change to the community you want the notice shown in and then post back to the confirm.php form. The change is ignored. I feel certain this is a simple thing to fix, but I can't figure it out.
Here is the edit.php file
Please help! Thanks loads!
Any suggestions how to keep the PHP variables in the form when the back button is used?
Here is a small portion of the info.php file
Code: Select all
<form method="post" action="confirm.php">
<div class="mediumtext1"><strong>Viewing Communities </strong></div>
<div class="note">Please specify where you want the notice shown.</div>
<br>
<label for="coudersport"> Coudersport
<input id="coudersport" name="coudersport" type="checkbox">
</label>
<label for="emporium"> Emporium
<input id="emporium" name="emporium" type="checkbox">
</label>
<label for="port"> Port Allegany
<input id="port" name="port" type="checkbox">
</label>
<input type="submit" name="Submit" value="Submit">
</form>Code: Select all
<form action="edit.php" method="post">
<? if(($coudersport != "") && ($emporium == "") && ($port == ""))
{ $where = "Coudersport";}
else if(($coudersport != "") && ($emporium != "") && ($port != ""))
{ $where = "All Communities";}
else if (($coudersport != "") && ($emporium != "") && ($port == ""))
{ $where = "Coudersport and Emporium";}
else if (($coudersport != "") && ($emporium == "") && ($port != ""))
{ $where = "Coudersport and Port Allegany"; }
else if (($coudersport == "") && ($emporium != "") && ($port == ""))
{ $where = "Emporium";}
else if (($coudersport == "") && ($emporium != "") && ($port != ""))
{ $where = "Emporium and Port Allegany";}
else if (($coudersport == "") && ($emporium == "") && ($port != ""))
{ $where = "Port Allegany"; }
?>
You have chosen to have the notice appear in <? print ($where); ?>
<input type="hidden" name="where" value="<? print($where);?>" />
<input type="submit" name="Submit" value="Edit">
</form>Here is the edit.php file
Code: Select all
<form method="post" action="confirm.php">
<div class="mediumtext1"><strong>Viewing Communities </strong></div>
<br>
You have indicated that your message or ad should be shown in <strong><?print($where);{?></strong>. <br>
If you want to make a change to the viewing communities, please make a new selection below.
<br><br>
<!-- code that prints the 'x' in the checkbox of the community selected. If AllTowns is checked, or if all 3 communities are checked, only the AllTowns box will have the 'x' -->
<label for="coudy"> Coudersport
<input id="coudy" name="coudy" type="checkbox">
</label>
<label for="emp"> Emporium
<input id="emp" name="emp" type="checkbox">
</label>
<label for="portA"> Port Allegany
<input id="portA" name="portA" type="checkbox">
</label>
<?
if(($coudy != "") && ($emp =="") && ($portA == ""))
{$where = "Coudersport";}
elseif (($coudy != "") && ($emp == "") && ($portA != ""))
{ $where = "Coudersport and Port Allegany"; }
elseif (($coudy == "") && ($emp != "") && ($portA == ""))
{ $where = "Emporium";}
elseif (($coudy == "") && ($emp != "") && ($portA != ""))
{ $where = "Emporium and Port Allegany";}
elseif (($coudy == "") && ($emp == "") && ($portA != ""))
{ $where = "Port Allegany"; }
elseif(($coudy != "") && ($emp != "") && ($portA != ""))
{ $where = "All Communities";}
elseif (($coudy != "") && ($emp != "") && ($portA == ""))
{ $where = "Coudersport and Emporium";}
?>
<input type="hidden" name="where" value="<? print($where);}?>" />
<input type="submit" name="Submit" value="Submit Change">
</form>