schoolmommy Posted April 24, 2007 Share Posted April 24, 2007 Hi! I'm working on a program that I've done in asp.net (using vb) but this time it has to be done using php. Basically, you have the user enter their info and have it displayed on an order confirmtion page. The page has a hyperlink for confirming the order. The link has to be invisible to begin with, but will display after the submit button has been clicked. I've included the code below that I had done so far. I'm to familiar with how a session works in php so I don't think my code is correct on the php page. Can this form be done using only a php page or do I need to have an html page and the php page? Am I right in assuming that you can't do a drop down box in php? It calls for one for the credit card, but I didn't see that option in the toolbar; just single radio buttons. Thanks! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Rough Riders Rodeo</title> </head> <body> <table border="0"> <caption> <h1> Rough Riders Rodeo</h1> </caption> <tr> <td style="width: 304px"> Num. of Tickets</td> <td style="width: 456px"> <input id="txtTickets" name="txtTickets" style="width: 48px" type="text" /></td> </tr> <tr> <td style="width: 304px"> Name</td> <td style="width: 456px"> <input id="txtName" name="txtName" size="40" type="text" /></td> </tr> <tr> <td style="width: 304px"> Address</td> <td style="width: 456px"> <input id="txtAddress" name="txtAddress" size="40" type="text" /></td> </tr> <tr> <td style="width: 304px"> City</td> <td style="width: 456px"> <input id="txtCity" name="txtCity" size="30" type="text" /></td> </tr> <tr> <td style="width: 304px"> State</td> <td style="width: 456px"> <input id="txtState" name="txtState" size="2" type="text" /></td> </tr> <tr> <td style="width: 304px"> Zip Code</td> <td style="width: 456px"> <input id="txtZip" name="txtZip" size="10" type="text" /></td> </tr> <tr> <td style="width: 304px"> Phone#</td> <td style="width: 456px"> <input id="txtPhone" name="txtPhone" size="13" type="text" /> (111-111-1111)</td> </tr> <tr> <td style="width: 304px; height: 45px;"> Credit Card Number</td> <td style="width: 456px; height: 45px;"> <input id="txtCreditCard" name="txtCreditCard" size="15" type="text" /> <input id="Radio1" type="radio" /> Visa <input id="Radio2" type="radio" /> MasterCard <input id="Radio3" type="radio" /> Discover <input id="Radio4" type="radio" /> AmEx</td> </tr> <tr> <td style="width: 304px"> Expiration Date</td> <td style="width: 456px"> <input id="txtExpire" name="txtExpire" size="10" type="text" /> (xx/xx/xxxx)</td> </tr> <tr> <td style="width: 304px"> <input id="ckbxAwards" name="ckbxAwards" size="1" type="checkbox" />Check here if you will be attending Awards Event?</td> <td style="width: 456px"> <input id="txtAwardsYesNo" name="txtAwardsYesNo" size="30" type="text" /></td> </tr> <tr> <td style="width: 304px"> </td> <td style="width: 456px"> <input id="btnSubmit" name="btnSubmit" type="submit" value="submit" /> <input id="btnOrderConfirmatin" name="btnOrderConfirmation" title="Order Confirmation" type="button" value="Order Confirmation" /></td> </tr> </table> </body> </html> php <? session_start(); if ((((((((((!$_Session[tickets]) || (!$_Session[name]) || (!$_Session[address]) || (!$_Session[city]) || (!$_Session[state]) || (!$_Session[zip]) || (!$_Session[phone]) || (!$_Session[crecitcard]) || (!$_Session[expire] || (!$_Session[awardsattend])))))))))) } else { $tickets = "txtTickets"; $name = "txtName"; $address = "txtAddress"; $city = "txtCity"; $state = "txtState"; $zip = "txtZip"; $phone = "txtPhone"; $creditcard = "txtCreditCard"; $expire = "txtExpire"; $attendawards = "txtAwardsYesNo"; } If btnOrderConfirmation.visible = False Then btnOrderConfirmation.visible = Ture End If If ckbxAwardsEvent.checked = True Then txtAwardsYesNo = "Will attend Awards Event" Else txtAwardsYesNo = "Will not be attending Awards Event" End If ?> <html> <head> <title>Order Confirmation</title> </head> <body> <h1>Order Confirmation</h1> <form method="POST" Action="frmConfirm.php"> <table border="0"> <caption> <h1> Rough Riders Rodeo</h1> </caption> <tr> <td style="width: 304px"> Num. of Tickets</td> <td style="width: 456px"> <input id="txtTickets" name="txtTickets" style="width: 48px" type="text" /></td> </tr> <tr> <td style="width: 304px"> Name</td> <td style="width: 456px"> <input id="txtName" name="txtName" size="40" type="text" /></td> </tr> <tr> <td style="width: 304px"> Address</td> <td style="width: 456px"> <input id="txtAddress" name="txtAddress" size="40" type="text" /></td> </tr> <tr> <td style="width: 304px"> City</td> <td style="width: 456px"> <input id="txtCity" name="txtCity" size="30" type="text" /></td> </tr> <tr> <td style="width: 304px"> State</td> <td style="width: 456px"> <input id="txtState" name="txtState" size="2" type="text" /></td> </tr> <tr> <td style="width: 304px"> Zip Code</td> <td style="width: 456px"> <input id="txtZip" name="txtZip" size="10" type="text" /></td> </tr> <tr> <td style="width: 304px"> Phone#</td> <td style="width: 456px"> <input id="txtPhone" name="txtPhone" size="13" type="text" /> (111-111-1111)</td> </tr> <tr> <td style="width: 304px; height: 45px;"> Credit Card Number</td> <td style="width: 456px; height: 45px;"> <input id="txtCreditCard" name="txtCreditCard" size="15" type="text" /> <input id="Radio1" type="radio" /> Visa <input id="Radio2" type="radio" /> MasterCard <input id="Radio3" type="radio" /> Discover <input id="Radio4" type="radio" /> AmEx</td> </tr> <tr> <td style="width: 304px"> Expiration Date</td> <td style="width: 456px"> <input id="txtExpire" name="txtExpire" size="10" type="text" /> (xx/xx/xxxx)</td> </tr> <tr> <td style="width: 304px"> <input id="ckbxAwards" name="ckbxAwards" size="1" type="checkbox" />Check here if you will be attending Awards Event?</td> <td style="width: 456px"> <input id="txtAwardsYesNo" name="txtAwardsYesNo" size="30" type="text" /></td> </tr> <tr> <td style="width: 304px"> </td> <td style="width: 456px"> <input id="btnSubmit" name="btnSubmit" type="submit" value="submit" /> <input id="btnOrderConfirmatin" name="btnOrderConfirmation" title="Order Confirmation" type="button" value="Order Confirmation" /></td> </tr> </table> <?php echo "$tickets"; ?> <?php echo "$name"; ?> <?php echo "$address"; ?> <?php echo "$city"; ?> <?php echo "$state"; ?> <?php echo "$zip"; ?> <?php echo "$phone"; ?> <?php echo "$creditcard"; ?> <?php echo "$expire"; ?> <?php echo "$attendawards"; ?> </body> </html> EDIT: Please wrap your code in code tags ( ). This helps to identify code form text (and keeps scrolling to a minimum ). Quote Link to comment Share on other sites More sharing options...
mpharo Posted April 24, 2007 Share Posted April 24, 2007 I assume in your if else statement you are trying to assign the $ variables to the same as the session variables? if this is the case you need to use them as session variables and not normal variables...like this... $_SESSION['tickets']="txtTickets"; echo $_SESSION['tickets']; Quote Link to comment Share on other sites More sharing options...
schoolmommy Posted April 24, 2007 Author Share Posted April 24, 2007 Thanks! Do I need an if/else for the radio buttons to know which one has been checked or will the session take care of that? I'm not sure of my syntax for those if/else statements to work in php. I don't think they are correct. If I put the html inside the php, then I shouldn't need the default page; is this correct? Also, the submit and order confirmation buttons don't seem to be working. Am I missing some code that should make them work? This is so much different than asp.net!!! Sorry for all the questions!!! Thanks! Quote Link to comment Share on other sites More sharing options...
mpharo Posted April 24, 2007 Share Posted April 24, 2007 In your if statements you are only required for one () around the comparison... In your <form> tag you do not have a closing </form> which is why the submit is not working.....in your order button your not telling it to do anything, you are just calling it a button, you need to use some javascript to do something with it like this... onClick="document.form.submit()" or something.... You need a comparison if statement for the radio buttons to be checked or unchecked with php... Quote Link to comment Share on other sites More sharing options...
Trium918 Posted April 24, 2007 Share Posted April 24, 2007 <?php // First of all the session always go before headers session_start(); <html> ?> Quote Link to comment Share on other sites More sharing options...
schoolmommy Posted April 24, 2007 Author Share Posted April 24, 2007 Hi! There should have been some astricks between the first html code and where the php starts. These are two different files. The first is a default.html file and the second is the php file. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.