problem with if..else condition

From: Date: Thu, 02 Oct 2003 04:14:22 +0000
Subject: problem with if..else condition
Groups: php.general 
Request: Send a blank email to php-general+get-164678@lists.php.net to get a copy of this message
Hi all, I'm having some problem with my PHP script here. Do hope to receive some help. I have written the script with a if..elseif..else ...condition to check if my checkbox have been checked. There is 3 radio button to be clicked: eg button1 , button 2 and button3.Only one to be checked at one time. Supposely "button1" is clicked, it should output "button1" as the selection once the submit button has been clicked. I have attached my HTMl and PHP code below. Hope to get some help here. HTML: <html> <head> <title>Payment Mode</title> <style type="text/css"> @import url(receipt.css); </style> </head> <body> <form action="checkbox.php" method="get"> <br><br><br> <div id="pagecontent1"> <div class="sectionheading"> Payment Mode:<br> </div> <div class="lighter"> <input type="radio" name="payment" value="Cash" >Cash<br> </div> <div class="darker"> <input ty<div class="sectionheading"> *For Cheque plus Cash payment only: </div> <div class="lighter"> Cheque: $ <input name="cheque" type="text" size="6" maxlength="6"><br> </div> <div class="darker"> Cash: $ <input name="cash" type="text" size="6" maxlength="6"><br></div><br> <input type="submit" name="submit" value="submit" align="center"> </div> </form> </form> </body></html>pe="radio" name="payment" value="Nets">Nets<br> </div> <div class="lighter"> <input type="radio" name="payment" value="Cheque">Cheque<br></div><br> PHP: <HTML> <HEAD> <title>Payment Mode</title> <style type="text/css"> @import url(receipt.css); </style> </HEAD> <BODY> <br><br> <div id="pagecontent1"> <div class="sectionheading"> <br> <tr> <td valign="top" class="darker" width="200"> <?php if ($payment==Cash AND $payment != Nets AND $payment != Cheque) { echo ("Payment Mode: Cash"); } elseif ($payment==Nets AND $payment != Cash AND $payment != Cheque ) { echo ("Payment Mode: Nets"); } } elseif ($payment==Cheque AND $payment != Nets AND $payment != Cheque) { echo ("Payment Mode: Cheque"); } else/* ($payment != Cash) AND ($payment != Nets) AND ($payment != Cheque)*/ { echo ("Payment Mode:Cash Plus Cheque"); } /* else { echo ("error!"); }*/ ?> <br> </div> </td> Cash: <?php echo "$$_GET[cheque]";?><BR> Cheque:<?php echo "$$_GET[cash]";?><BR> <br> <?php $total = $_GET[cheque] + $_GET[cash]; $total=number_format($total, 2, ".", " "); echo "<BR>Total payable: $$total<BR><BR>"; ?> </div> </BODY> </HTML>

« previous php.general (#164678) next »