Forum Moderators: coopster
The basic issue: I need to pass a form variable ("PartnerName"[smilestopper]) to a PHP variable another page, which is invoked as the action on a Submit button. On the second page I want to make decisions using a Switch/Case control block.
The problem: no matter what I try -- and I've looked at many "solutions" online - I simply can't seem to get the variable's value to transfer.
One twist: the variable in question, "PartnerName", I managed to get to come from a prior page (index.html). So I just need to pass this var's value along to a third page:
index.html - "PartnerName" ---> content passed to page2.php
page2.html - "PartnerName" ---> does NOT come across to page3.php
Relevant snippets of code:
[from index.html]:
<form name="Partners" method="post" action="pape2.php">
<input type="hidden" name="PartnerName" value="">
<div align="center">
<select name="Partners" onChange="document.Partners.PartnerName.value=this.value">
<option selected>< Choose a Partner ></option>
<option value="WAG">Bill Goth</option>
<option value="WRN">Bill Nuts Norwalk</option>
</select>
</div>
<input type="submit" value="Submit IT!">
</form>
[from page2.php:]
<?php
// Retrieve the hidden form variable (using PHP).
$PassedVar = $_POST['PartnerName'];
$PartnerName=$PassedVar;
?>
<form action="page3.php" method="post" enctype="multipart/form-data" name="taxassign" target="_self">
<input type ="hidden" name="PartnerPassed" value="<?=$PartnerName?>" />
<select name= "Role">
<option selected value="">Choose One</option>
<option value="Admin">Admin</option>
<option value="Partner">Partner</option>
<option value="TesterJ">James</option>
<option value="TesterB">Brian</option>
</select>
<input name="submit" type="submit" value="Submit">
[from page3.php - note that "Role comes across, but not "PartnerName"]:
// Receiving variables
@$PartnerName = $_GET['PartnerPassed'];
@$PassedVar = addslashes($_POST['PassedVar']);
...
Switch ($PartnerName)
{
Case "WAG":
Switch ($Role)
{
Case "Admin":
$email_to = "emailaddr0@domain.com"; // tax manager
$email_from = "emailaddr1@domain.com"; // for proper formatting of email Sent From header
break;
::::::::
The Switch statement sees $PartnerName as being empty...! And that's the heart of my problem.
Any help is ENORMOUSLY appreciated!
You may want to avoid the use of short tags (and the shorthand echo method). It causes issues if you ever need to handle XML tags (which also start with a
<?) and because short tags will be completely disabled in future versions of PHP.
Just replace
<?=$var;?>with
<?php echo $var;?>and you'll be all set. :)