By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,806 Members | 1,490 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,806 IT Pros & Developers. It's quick & easy.

want an alternative submit

P: n/a
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>

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"edward hage" a écrit le 14/12/2003 :
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 ?


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/

Jul 17 '05 #2

P: n/a
edward hage wrote:
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>


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>

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.