I am having problem getting PHP to pass the correct variable from a form.
The case
-----------
I have one form which generate's 2 different type of replies automatically depending on which one of the variable it gets from the form.
Like for an example
Choose : Trial (radiobutton) Purchase(radiobutton)
If the user chooses Purchase, fills up the rest of the form and hit's submit then Reply B will be sent to the administrator else Reply A will be sent.
I can make this to work if I have different name for the fields like for an example
<input name="trial" value="trial" type="radio"/>Purchase
<input name="purchase" value="purchase" type="radio"/>Trial
The problem is, if I have different name, then I cannot have a validation script for this because it asks to fill both the field just because it has different Name
If I put the same name .. like for an example
<input name="selection" value="trial" type="radio"/>Purchase
<input name="selection" value="purchase" type="radio"/>Trial
then it only sents Reply A even if I choose Purchase as my option.
My code looks like this
--------------------------
<?
if ($Selection = Trial)
{
$to = "email@w.sag";
$subject = "Reply A";
$body="";
$fd = fopen ("trial.html", "r");
while (!feof ($fd))
{ $buffer = fgets($fd, 4096);
$body .= $buffer;
if (!strlen($buffer)) continue;
}
fclose ($fd);
$body = preg_replace("/#XXX#/", $XXX, $body);
$body = preg_replace("/#XXX#/", $XXX, $body);
} else {
$to = "email@w.sag";
$subject = "Reply B";
$body="";
$fd = fopen ("purchase.html", "r");
while (!feof ($fd))
{ $buffer = fgets($fd, 4096);
$body .= $buffer;
if (!strlen($buffer)) continue;
}
fclose ($fd);
$body = preg_replace("/#XXX#/", $XXX, $body);
$body = preg_replace("/#XXX#/", $XXX, $body);
}
?>
If I replace if ($Selection = Trial) with if ($trial)
the form works. I am trying my best to have the the Radio field name the same so i could have a validation script for it. Any ideas are highly appreciated. Thanks a million