Connecting Tech Pros Worldwide Forums | Help | Site Map

want an alternative submit

edward hage
Guest
 
Posts: n/a
#1: Jul 17 '05
Hello,

When filling in a form I want to be able to go to ways,
first way when pushed "Continue" and second way by pushing "A" as
indicated below.

Problem is that input type button does not post the name, with other
words $_POST['A'] does not exist. How can I overcome this problem ?

One way is to add a checkbox in which the choice can be made and one
submit but that is a bit ugly.



<?php
if ($_POST['A']) {
echo "PUSHED ON THE A-BUTTON".$_POST['A'];
}
else {
echo "PUSHED ON SUBMIT";
}
?>
<BR><BR><BR><BR><BR><BR>
<FORM ACTION="<?=$PHP_SELF ?>" METHOD='POST'>
<INPUT TYPE="SUBMIT" VALUE="Continue">
<INPUT TYPE="BUTTON" NAME="A" VALUE=" A " >
</FORM>


Jedi121
Guest
 
Posts: n/a
#2: Jul 17 '05

re: want an alternative submit


"edward hage" a écrit le 14/12/2003 :[color=blue]
> When filling in a form I want to be able to go to ways,
> first way when pushed "Continue" and second way by pushing "A" as indicated
> below.
>
> Problem is that input type button does not post the name, with other words
> $_POST['A'] does not exist. How can I overcome this problem ?[/color]

Try two submit fields with different names :
<?php
print_r($_POST);
?>
<form action="<?=$PHP_SELF ?>" method='POST'>
<input type='submit' name='continue' value='Continue'>
<input type='submit' name='A' value=' A '>
</form>

--
Have you read the manual?
http://www.php.net/manual/en/

edward hage
Guest
 
Posts: n/a
#3: Jul 17 '05

re: want an alternative submit


edward hage wrote:[color=blue]
> Hello,
>
> When filling in a form I want to be able to go to ways,
> first way when pushed "Continue" and second way by pushing "A" as
> indicated below.
>
> Problem is that input type button does not post the name, with other
> words $_POST['A'] does not exist. How can I overcome this problem ?
>
> One way is to add a checkbox in which the choice can be made and one
> submit but that is a bit ugly.
>
>
>
> <?php
> if ($_POST['A']) {
> echo "PUSHED ON THE A-BUTTON".$_POST['A'];
> }
> else {
> echo "PUSHED ON SUBMIT";
> }
> ?>
> <BR><BR><BR><BR><BR><BR>
> <FORM ACTION="<?=$PHP_SELF ?>" METHOD='POST'>
> <INPUT TYPE="SUBMIT" VALUE="Continue">
> <INPUT TYPE="BUTTON" NAME="A" VALUE=" A " >
> </FORM>
>[/color]

Oeps, posted too soon. Just had a brainwave and this works.

The solution is always more simple than you first imagine, oh well 2
hours of trial-and-error .

<?php
if ($_POST['A']=="other") {
echo "PUSHED ON THE OTHER-BUTTON".$_POST['A'];
}
else {
echo "PUSHED ON SUBMIT";
}
?>
<BR><BR><BR><BR><BR><BR>
<FORM ACTION="<?=$PHP_SELF ?>" METHOD='POST'>
<INPUT TYPE="SUBMIT" NAME="A" VALUE="Continue">
<INPUT TYPE="SUBMIT" NAME="A" VALUE="other" >
</FORM>

Closed Thread