
learningcurve
Members-
Posts
44 -
Joined
-
Last visited
Everything posted by learningcurve
-
I know this can be done, but I just can't write the javascript correctly to make it work. I have these two form elements: <input type="radio" name="JECT" value="no" checked <?php if(@$JECT=="no"){ echo "checked";}?>> No thanks</br> <input type='radio' name='JECT' value='JECTindividual_print' <?php if(@$JECT=="JECTindividual_print"){ echo "checked";}?>> Print subscription (US and Canada only): US $<?php echo $JECTindividual_print_price['base']['United States']; ?>, Canada $<?php echo $JECTindividual_print_price['base']['Canada']; ?></br> <input type='radio' name='JECT' value='JECTindividual_electronic' <?php if(@$JECT=="JECTindividual_electronic"){ echo "checked";}?>> Electronic subscription (access to complete online archive): $<?php echo $JECTindividual_electronic_price['base']; ?></br> <input type='radio' name='JECT' value='JECTindividual_combo' <?php if(@$JECT=="JECTindividual_combo"){ echo "checked";}?>> Combination print and electronic subscription (US and Canada only): $<?php echo $JECTindividual_combo_price['base']; ?></br> <p style="text-indent:30px;">Length of subscription:</br></p> <label><input type="radio" name="JECTsub" value="1" checked <?php if(@$JECTsub=="1"){ echo "checked";}?>> 1 year</label></br> <label><input type="radio" name="JECTsub" value="2" <?php if(@$JECTsub=="2"){ echo "checked";}?>> 2 years</label></br> <label><input type="radio" name="JECTsub" value="3" <?php if(@$JECTsub=="3"){ echo "checked";}?>> 3 years</label></br> <label><input type='checkbox' name='JECTrenewal' value='yes' <?php if(@$JECTrenewal=="yes"){ echo "checked";}?>> Check box if this is a renewal</label></br> If the "no" radio button is checked (in other words, if $JECT="no", I want the JECTsub radio buttons to not show. if any other value is chosen for JECT, I want the JECTsub buttons to show. Thanks ahead for the help.
-
<td>size 2 <br /><input type="radio" value="2" name="size" /></td> <td>Size 4 <br /><input type="radio" value="4" name="size" /></td> <td>Size 8 <br /><input type="radio" value="8" name="size" /></td> You already have three radio buttons with the sizes - just add the price to the radio text (which you might want to clean up a little). Unless you need to have different prices for bus/res and if you actually need to do something with those prices - like calculations, etc. So...do you need PHP or is this an HTML coding issue?
-
Total off by penny - can't figure out how
learningcurve replied to learningcurve's topic in PHP Coding Help
Thanks Psycho, for the helpful tips. And of course, big thanks to mac_gyver. I consider you a genius and wish you were my personal Yoda. It would make learning php a lot easier. You were on spot. Once this is working, I am going to go back and see if I can weed it - there is way too much. Slowly learning how to crawl... -
I have an order site. I wrote some of the code, but not all. When someone orders from this page: <?php include 'header.php'; if(isset($_POST['redo'])){ extract($_POST); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Journal Individual Order Form</title> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"> <link href="http://celt.edu/ject/images/favicon.png" rel="shortcut icon"> <style type="text/css"> </style> <script type="text/javascript"> function remove_space(ids,vals){ document.getElementById(ids).value=vals.replace(/(^\s*)/g, ""); var new_txt=document.getElementById(ids).value; document.getElementById(ids).value=new_txt.replace(/'/g, ""); } function form_validate(){ var name=document.getElementById('firstname').value; var lname=document.getElementById('lastname').value; var email=document.getElementById('email').value; var phone=document.getElementById('phone').value; var address=document.getElementById('address').value; var city=document.getElementById('city').value; var zip=document.getElementById('zip').value; var regemail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,6})$/; var mess=""; if(name==""){ mess= mess+"Please Enter Your First Name \n"; } if(lname==""){ mess= mess+"Please Enter Your Last Name \n"; } if(phone==""){ mess= mess+"Phone cannot be Blank \n"; } if(email==""){ mess= mess+"Email cannot be Blank \n"; } if(email!=""){ if(! regemail.test(email)){ mess= mess+"Invalid Email Format \n"; } } if(address==""){ mess= mess+"Please Enter Your Street \n"; } if(city==""){ mess= mess+"Please Enter Your City \n"; } if(zip==""){ mess= mess+"Please Enter Your Zip \n"; } if(document.subscriptionForm.payment_method[0].checked==false && (document.subscriptionForm.payment_method[1].checked==false && document.subscriptionForm.payment_method[2].checked==false)){ mess= mess+"Please Select The Payment Type \n"; } if(mess){ alert(mess); return false; } return true; } </script> </head> <body onLoad="recalc()"> <h1 style="margin-top: 0;">Individual subscription order form</h1> <h2><b><FONT COLOR="#C41230">Discounts are offered to subscribers who purchase subscriptions for two or more CELTUA journals.</FONT></b></h2> <h3>Choose two journals for <?php echo DISCOUNT_2Journals_per; ?>% off your total order or subscribe to all three for <?php echo DISCOUNT_3Journals_per; ?>% off your total order. </h3> <p>Individual subscriptions can be done three ways: </p> <ul> <li> an individual print subscription, shipped to the address you provide <ul> <li>4 issues per year for <em>Journal on Excellence</em>, new subscriptions will start with Volume <?php echo $JECTsubscribeVolume['vol']; ?>, <?php echo $JECTsubscribeVolume['year']; ?></li> <li>1 issue per year for <em>Journal on Centers</em>, new subscriptions will start with Volume <?php echo $JCTLsubscribeVolume['vol']; ?>, <?php echo $JCTLsubscribeVolume['year']; ?></li> <li>1 issue per year for <em>Learning Communities</em>, new subscriptions will start with Volume <?php echo $LCJsubscribeVolume['vol']; ?>, <?php echo $LCJsubscribeVolume['year']; ?></li> </ul> </li> <li>an individual electronic subscription (access to complete online archive) -- electronic subscribers can browse articles by issue and search article abstracts</li> <li>a combination print and electronic subscription at a special discount rate</li> </ul> <p>Select the subscription option that suits your needs using the form below. Print subscriptions can only be shipped to the US and Canada.</p> <form action='order_review.php' method='post' id='subscriptionForm' name="subscriptionForm" onsubmit="return form_validate()"> <input type="hidden" name="subscription_type" value="individual"/> <input type="hidden" name="id_subcount" value="" id="id_subcount"/> <input type="hidden" name="jectprice_hidden" id="jectprice_hidden" value=""/> <input type="hidden" name="jctlprice_hidden" id="jctlprice_hidden" value=""/> <input type="hidden" name="lcjprice_hidden" id="lcjprice_hidden" value=""/> <h2>Recipient's contact information</h2> <table> <tr> <th>First name:</th> <td><input type='text' name='firstname' id="firstname" onblur="remove_space(this.id,this.value)" value="<?php if(isset($firstname)) { echo $firstname;} ?>" /></td> </tr> <tr> <th>Last name:</th> <td><input type='text' name='lastname' value="<?php if(isset($lastname)) { echo $lastname;} ?>" onblur="remove_space(this.id,this.value)" id="lastname"/></td> </tr> <tr> <th>Department (if applicable):</th> <td><input type='text' name='department' value="<?php if(isset($department)) { echo $department;} ?>" onblur="remove_space(this.id,this.value)" id="department"/></td> </tr> <tr> <th>Institution (if applicable):</th> <td><input type='text' name='institution' value="<?php if(isset($institution)) { echo $institution;} ?>" onblur="remove_space(this.id,this.value)" id="institution"/></td> </tr> <tr> <th>Phone number:</th> <td><input type='text' name='phone' value="<?php if(isset($phone)) { echo $phone;} ?>" onblur="remove_space(this.id,this.value)" id="phone"/></td> </tr> <tr> <th>Email address:</th> <td><input type='text' name='email' value="<?php if(isset($email)) { echo $email;} ?>" onblur="remove_space(this.id,this.value)" id="email"/></td> </tr> <tr> <th>Street address:</th> <td><textarea name='address' cols='40' rows='5' onblur="remove_space(this.id,this.value)" id="address"/><?php if(isset($address)) { echo $address;} ?></textarea></td> </tr> <tr> <th>City:</th> <td><input type='text' name='city' value="<?php if(isset($city)) { echo $city;} ?>" onblur="remove_space(this.id,this.value)" id="city"/></td> </tr> <tr> <th>State/Province:</th> <td><input type='text' name='state' value="<?php if(isset($state)) { echo $state;} ?>" onblur="remove_space(this.id,this.value)" id="state"/></td> </tr> <tr> <th>ZIP/Postal code:</th> <td><input type='text' name='zip' value="<?php if(isset($zip)) { echo $zip;} ?>" onblur="remove_space(this.id,this.value)" id="zip"/></td> </tr> <tr> <th>Country:</th> <td> <select name='usCan' id="usCan"> <option value='United States' >United States</option> <option value='Canada' >Canada</option> <option value='Other' >Other:</option> </select> <input type='text' name='country' id='country' value="<?php if(isset($usCan)) { echo $usCan;} ?>" > </td> </tr> </table> <h2>Subscription Options</h2> <h3>Please choose the options you desire.</h3> <FONT SIZE="+1"> <h3><b><em>Journal on Excellence</em></b></h3> </FONT> <input type="radio" name="JECT" value="no" checked <?php if(@$JECT=="no"){ echo "checked";}?>> No thanks</br> <input type='radio' name='JECT' value='JECTindividual_print' <?php if(@$JECT=="JECTindividual_print"){ echo "checked";}?>> Print subscription (US and Canada only): US $<?php echo $JECTindividual_print_price['base']['United States']; ?>, Canada $<?php echo $JECTindividual_print_price['base']['Canada']; ?></br> <input type='radio' name='JECT' value='JECTindividual_electronic' <?php if(@$JECT=="JECTindividual_electronic"){ echo "checked";}?>> Electronic subscription (access to complete online archive): $<?php echo $JECTindividual_electronic_price['base']; ?></br> <input type='radio' name='JECT' value='JECTindividual_combo' <?php if(@$JECT=="JECTindividual_combo"){ echo "checked";}?>> Combination print and electronic subscription (US and Canada only): $<?php echo $JECTindividual_combo_price['base']; ?></br> <p style="text-indent:30px;">Length of subscription:</br></p> <label><input type="radio" name="JECTsub" value="1" checked <?php if(@$JECTsub=="1"){ echo "checked";}?>> 1 year</label></br> <label><input type="radio" name="JECTsub" value="2" <?php if(@$JECTsub=="2"){ echo "checked";}?>> 2 years</label></br> <label><input type="radio" name="JECTsub" value="3" <?php if(@$JECTsub=="3"){ echo "checked";}?>> 3 years</label></br> <label><input type='checkbox' name='JECTrenewal' value='yes' <?php if(@$JECTrenewal=="yes"){ echo "checked";}?>> Check box if this is a renewal</label></br> <FONT SIZE="+1"> <h3><b><em>Journal on Centers</em></b></h3> </FONT> <input type="radio" name="JCTL" value="no" checked <?php if(@$JCTL=="no"){ echo "checked";}?>> No thanks</br> <input type='radio' name='JCTL' value='JCTLindividual_print' <?php if(@$JCTL=="JCTLindividual_print"){ echo "checked";}?>> Print subscription (US and Canada only): US $<?php echo $JCTLindividual_print_price['base']['United States']; ?>, Canada $<?php echo $JCTLindividual_print_price['base']['Canada']; ?></br> <input type='radio' name='JCTL' value='JCTLindividual_electronic' <?php if(@$JCTL=="JCTLindividual_electronic"){ echo "checked";}?>> Electronic subscription (access to complete online archive): $<?php echo $JCTLindividual_electronic_price['base']; ?></br> <input type='radio' name='JCTL' value='JCTLindividual_combo' <?php if(@$JCTL=="JCTLindividual_combo"){ echo "checked";}?>> Combination print and electronic subscription (US and Canada only): $<?php echo $JCTLindividual_combo_price['base']; ?></br> <p style="text-indent:30px;">Length of subscription:</br></p> <label><input type="radio" name="JCTLsub" value="1" checked <?php if(@$JCTLsub=="1"){ echo "checked";}?>> 1 year</label></br> <label><input type="radio" name="JCTLsub" value="2" <?php if(@$JCTLsub=="2"){ echo "checked";}?>> 2 years</label></br> <label><input type="radio" name="JCTLsub" value="3" <?php if(@$JCTLsub=="3"){ echo "checked";}?>> 3 years</label></br> <label><input type='checkbox' name='JCTLrenewal' value='yes' <?php if(@$JCTLrenewal=="yes"){ echo "checked";}?>> Check box if this is a renewal</label></br> <FONT SIZE="+1"> <h3><b><em>Learning Communities</em></b></h3> </FONT> <input type="radio" name="LCJ" value="no" checked <?php if(@$LCJ=="no"){ echo "checked";}?>> No thanks</br> <input type='radio' name='LCJ' value='LCJindividual_print' <?php if(@$LCJ=="LCJindividual_print"){ echo "checked";}?>> Print subscription (US and Canada only): US $<?php echo $LCJindividual_print_price['base']['United States']; ?>, Canada $<?php echo $LCJindividual_print_price['base']['Canada']; ?></br> <input type='radio' name='LCJ' value='LCJindividual_electronic' <?php if(@$LCJ=="LCJindividual_electronic"){ echo "checked";}?>> Electronic subscription (access to complete online archive): $<?php echo $LCJindividual_electronic_price['base']; ?></br> <input type='radio' name='LCJ' value='LCJindividual_combo' <?php if(@$LCJ=="LCJindividual_combo"){ echo "checked";}?>> Combination print and electronic subscription (US and Canada only): $<?php echo $LCJindividual_combo_price['base']; ?></br> <p style="text-indent:30px;">Length of subscription:</br></p> <label><input type="radio" name="LCJsub" value="1" checked <?php if(@$LCJsub=="1"){ echo "checked";}?>> 1 year</label></br> <label><input type="radio" name="LCJsub" value="2" <?php if(@$LCJsub=="2"){ echo "checked";}?>> 2 years</label></br> <label><input type="radio" name="LCJsub" value="3" <?php if(@$LCJsub=="3"){ echo "checked";}?>> 3 years</label></br> <label><input type='checkbox' name='LCJrenewal' value='yes' <?php if(@$LCJrenewal=="yes"){ echo "checked";}?>> Check box if this is a renewal</label></br> <h2>Payment</h2> <h3 id="grandTotal">Total: $0.00</h3> <input type="hidden" name="total"> <input type="hidden" name="subtotal"> <input type="hidden" name="discount"> <input type="hidden" name="itemprice1"> <input type="hidden" name="itemprice2"> <input type="hidden" name="itemprice3"> <p>Please indicate how you wish to pay:</p> <table class="payment"> <tr> <td> <input type='radio' name='payment_method' value='Credit card (online)' <?php if(@$payment_method=="Credit card (online)"){ echo "checked";}?>> <b>Credit card (online)</b> </td> <td> You will be taken to our secure payment site once you verified your order. Please have your credit card ready. <strong>(MasterCard, Visa, Discover, or American Express)</strong> </td> </tr> <tr> <td> <input type='radio' name='payment_method' value='Credit card (phone)' <?php if(@$payment_method=="Credit card (phone)"){ echo "checked";}?>> <b>Credit card (phone)</b> </td> <td> Please contact Matthew to make your payment. <strong>(MasterCard or Visa only)</strong> </td> </tr> <tr> <td> <input type='radio' name='payment_method' value='Check' <?php if(@$payment_method=="no"){ echo "Check";}?>> <b>Check or Money order</b></td> <td>Please make check or money order to:</br> Subscription Manager</td> </tr> </table> <p>Once you have completed this form and agree to the above terms, click the "Continue" button below to review your order and view your invoice. Your order will not be placed until you approve the invoice in the next step.</p> <p><input type="submit" name="submit" value="Continue"></p> </form> </div> <!-- end of mainbody --> <script type="text/javascript"> var prices = { "United States" : { "JECT" : [ 0, <?php echo $JECTindividual_print_price['base']['United States'] ?>, <?php echo $JECTindividual_electronic_price['base'] ?>, <?php echo $JECTindividual_combo_price['base'] ?> ], "JCTL" : [ 0, <?php echo $JCTLindividual_print_price['base']['United States'] ?>, <?php echo $JCTLindividual_electronic_price['base'] ?>, <?php echo $JCTLindividual_combo_price['base'] ?> ], "LCJ" : [ 0, <?php echo $LCJindividual_print_price['base']['United States'] ?>, <?php echo $LCJindividual_electronic_price['base'] ?>, <?php echo $LCJindividual_combo_price['base'] ?> ], "JECT_10" : [ 0, <?php echo $JECTindividual_print_price['10']['United States'] ?>, <?php echo $JECTindividual_electronic_price['10'] ?>, <?php echo $JECTindividual_combo_price['10'] ?> ], "JCTL_10" : [ 0, <?php echo $JCTLindividual_print_price['10']['United States'] ?>, <?php echo $JCTLindividual_electronic_price['10'] ?>, <?php echo $JCTLindividual_combo_price['10'] ?> ], "LCJ_10" : [ 0, <?php echo $LCJindividual_print_price['10']['United States'] ?>, <?php echo $LCJindividual_electronic_price['10'] ?>, <?php echo $LCJindividual_combo_price['10'] ?> ], "JECT_15" : [ 0, <?php echo $JECTindividual_print_price['15']['United States'] ?>, <?php echo $JECTindividual_electronic_price['15'] ?>, <?php echo $JECTindividual_combo_price['15'] ?> ], "JCTL_15" : [ 0, <?php echo $JCTLindividual_print_price['15']['United States'] ?>, <?php echo $JCTLindividual_electronic_price['15'] ?>, <?php echo $JCTLindividual_combo_price['15'] ?> ], "LCJ_15" : [ 0, <?php echo $LCJindividual_print_price['15']['United States'] ?>, <?php echo $LCJindividual_electronic_price['15'] ?>, <?php echo $LCJindividual_combo_price['15'] ?> ] }, "Canada" : { "JECT" : [ 0, <?php echo $JECTindividual_print_price['base']['Canada'] ?>, <?php echo $JECTindividual_electronic_price['base'] ?>, <?php echo $JECTindividual_combo_price['base'] ?> ], "JCTL" : [ 0,<?php echo $JCTLindividual_print_price['base']['Canada'] ?>, <?php echo $JCTLindividual_electronic_price['base'] ?>, <?php echo $JCTLindividual_combo_price['base'] ?> ], "LCJ" : [ 0, <?php echo $LCJindividual_print_price['base']['Canada'] ?>, <?php echo $LCJindividual_electronic_price['base'] ?>, <?php echo $LCJindividual_combo_price['base'] ?> ], "JECT_10" : [ 0, <?php echo $JECTindividual_print_price['10']['Canada'] ?>, <?php echo $JECTindividual_electronic_price['10'] ?>, <?php echo $JECTindividual_combo_price['10'] ?> ], "JCTL_10" : [ 0,<?php echo $JCTLindividual_print_price['10']['Canada'] ?>, <?php echo $JCTLindividual_electronic_price['10'] ?>, <?php echo $JCTLindividual_combo_price['10'] ?> ], "LCJ_10" : [ 0, <?php echo $LCJindividual_print_price['10']['Canada'] ?>, <?php echo $LCJindividual_electronic_price['10'] ?>, <?php echo $LCJindividual_combo_price['10'] ?> ], "JECT_15" : [ 0, <?php echo $JECTindividual_print_price['15']['Canada'] ?>, <?php echo $JECTindividual_electronic_price['15'] ?>, <?php echo $JECTindividual_combo_price['15'] ?> ], "JCTL_15" : [ 0,<?php echo $JCTLindividual_print_price['15']['Canada'] ?>, <?php echo $JCTLindividual_electronic_price['15'] ?>, <?php echo $JCTLindividual_combo_price['15'] ?> ], "LCJ_15" : [ 0, <?php echo $LCJindividual_print_price['15']['Canada'] ?>, <?php echo $LCJindividual_electronic_price['15'] ?>, <?php echo $LCJindividual_combo_price['15'] ?> ] }, "Other" : { "JECT" : [ 0, -1, <?php echo $JECTindividual_electronic_price['base'] ?>, -1 ], "JCTL" : [ 0, -1, <?php echo $JCTLindividual_electronic_price['base'] ?>, -1 ], "LCJ" : [ 0, -1, <?php echo $LCJindividual_electronic_price['base'] ?>, -1 ] } }; var form = document.getElementById("subscriptionForm"); // set up the calls to recalc from all checkboxes and radio buttons var inps = form.getElementsByTagName("input"); for ( var i = 0; i < inps.length; ++i ) { var inp = inps[i]; if ( inp.type == "checkbox" || inp.type == "radio" ) { inp.onclick = recalc; } } // and also from a change of country: form.usCan.onchange = recalc; function groupValue( group ) { for ( var g = 0; g < group.length; ++g ) { if ( group[g].checked ) return g; } return 0; } function recalc( ) { var msg = document.getElementById("grandTotal"); var country = form.usCan.value; var priceTable = prices[country]; var ject = groupValue( form.JECT ); var jctl = groupValue( form.JCTL ); var lcj = groupValue( form.LCJ ); var jectprice_hidden=0; var jctlprice_hidden=0; var lcjprice_hidden=0; var subcount = ( ject > 0 ? 1 : 0 ) + ( jctl > 0 ? 1 : 0 ) + ( lcj > 0 ? 1 : 0 ); var jectprice = priceTable["JECT"][ ject ]; var jctlprice = priceTable["JCTL"][ jctl ]; var lcjprice = priceTable["LCJ" ][ lcj ]; if(subcount==1){ var jectprice_hidden = priceTable["JECT"][ ject ]; var jctlprice_hidden = priceTable["JCTL"][ jctl ]; var lcjprice_hidden = priceTable["LCJ" ][ lcj ]; } if(subcount==2){ var jectprice_hidden = priceTable["JECT_10"][ ject ]; var jctlprice_hidden = priceTable["JCTL_10"][ jctl ]; var lcjprice_hidden = priceTable["LCJ_10" ][ lcj ]; } if(subcount==3){ var jectprice_hidden = priceTable["JECT_15"][ ject ]; var jctlprice_hidden = priceTable["JCTL_15"][ jctl ]; var lcjprice_hidden = priceTable["LCJ_15" ][ lcj ]; } if ( jectprice < 0 || jctlprice < 0 || lcjprice < 0 ) { msg.innerHTML = '<span style="color: red;">' + "You can not order print or combo editions from outside the US and Canada" + '</span>'; return -1; } var y_ject = groupValue( form.JECTsub ) + 1; var y_jctl = groupValue( form.JCTLsub ) + 1; var y_lcj = groupValue( form.LCJsub ) + 1; var total = jectprice * y_ject + jctlprice * y_jctl + lcjprice * y_lcj; var total_hidden = jectprice_hidden * y_ject + jctlprice_hidden * y_jctl + lcjprice_hidden * y_lcj; // alert(total_hidden); if(total_hidden){ document.getElementById('jectprice_hidden').value=jectprice_hidden; document.getElementById('jctlprice_hidden').value=jctlprice_hidden; document.getElementById('lcjprice_hidden').value=lcjprice_hidden; } var discount=0; var discount_price=0; if ( subcount == 2 ) { discount_price = <?php echo DISCOUNT_2Journals; ?> * total; // 10% discount discount=<?php echo DISCOUNT_2Journals_per; ?> } else if ( subcount == 3 ) { discount_price = <?php echo DISCOUNT_3Journals; ?> * total; // 15% discount discount=<?php echo DISCOUNT_3Journals_per; ?> } var msgtext = "Total: $" + total.toFixed(2); if ( discount_price >= 0 ) { msgtext += "<br/>Discount: -" + discount+"%"; var subtotal=total; total -= discount_price; if(total_hidden){ msgtext += "<br/>Grand total: $" + total_hidden.toFixed(2); } else{ msgtext += "<br/>Grand total: $" + total.toFixed(2); } } msg.innerHTML = msgtext; form.total.value = total.toFixed(2); form.subtotal.value = subtotal.toFixed(2); form.discount.value = discount; form.itemprice1.value = jectprice.toFixed(2); form.itemprice2.value = jctlprice.toFixed(2); form.itemprice3.value = lcjprice.toFixed(2); document.getElementById('id_subcount').value=subcount; return total; } </script> <?php include 'footer.php'; ?> </body> </html> It calculates the total correctly. When the information is passed to orderreview and then on to be processed, the total can be different. Here is the orderreview code: <?php include 'header.php'; include 'functions.php'; //print_r($_REQUEST);exit; extract($_REQUEST); $back_url=basename($_SERVER['HTTP_REFERER']); echo '<h2 style="margin-top: 0;">Review your order:</h2>'; echo '<p><b>Order for:</b></p>'; echo $_POST['firstname'].' '.$_POST['lastname'].'<br>'; if ($_POST['department']!='') echo $_POST['department'].'<br>'; if ($_POST['institution']!='') echo $_POST['institution'].'<br>'; //echo str_replace($returns,'<br>',$_POST['address']).'<br>'; echo $_POST['city'].', '.$_POST['state'].' '.$_POST['zip'].'<br>'; echo $country.'<br>'; echo $_POST['phone'].'<br>'; echo $_POST['email'].'</address>'; if($id_subcount==2){ $discount_rate=DISCOUNT_2Journals; } elseif($id_subcount==3){ $discount_rate=DISCOUNT_3Journals; }else{ $discount_rate=""; } ?> <table border="1"> <tr><th>Item</th><th>Base Price</br>(Single Year)</th><th>Your Price</br>(Single Year)</th><th>Length</th><th>Renewal?</th> <?php if ($subscription_type == "institutional") { ?> <th>Tier</th> <?php } ?> </tr> <?php $originalprice1 = $itemprice1 ?> <?php $originalprice2 = $itemprice2 ?> <?php $originalprice3 = $itemprice3 ?> <?php if($JECT && $JECT!="no"){ if($jectprice_hidden){ $itemprice1=$jectprice_hidden; } else { $itemprice1=$itemprice1; } ?> <tr> <td> <?php $JECTtext = $JECT; switch ($JECTtext) { case "JECTindividual_print": echo "Journal on Excellence (JECT) Individual Print Subscription"; break; case "JECTindividual_electronic": echo "Journal on Excellence (JECT) Individual Electronic Subscription"; break; case "JECTinstitutional_electronic": echo "Journal on Excellence(JECT) Insitutional Subscription"; break; case "JECTindividual_combo": echo "Journal on Excellence (JECT) Individual Combo Subscription"; break; case "JECTinstitutional_print": echo "Journal on Excellence (JECT) Institutional Print Subscription"; break; default: echo "Journal on Excellence (JECT) subscription"; } ?> </td> <td><?php echo $originalprice1; ?></td> <td><?php echo round($itemprice1,2); ?></td> <td><?php echo $JECTsub; ?></td> <td><?php if($JECTrenewal){ echo "Yes";} else { echo "No";} ?></td> <?php if ($subscription_type == "institutional") { ?> <td><?php echo $tier; ?></td> <?php } ?> </tr> <?php } ?> <?php if($JCTL && $JCTL!="no"){ if($jctlprice_hidden){ $itemprice2=$jctlprice_hidden; } else { $itemprice2=$itemprice2; } ?> <tr> <td> <?php $JCTLtext = $JCTL; switch ($JCTLtext) { case "JCTLindividual_print": echo "Journal on Centers(JCTL) Individual Print Subscription"; break; case "JCTLindividual_electronic": echo "Journal on Centers (JCTL) Individual Electronic Subscription"; break; case "JCTLinstitutional_electronic": echo "Journal on Centers (JCTL) Insitutional Subscription"; break; case "JCTLindividual_combo": echo "Journal on Centers (JCTL) Individual Combo Subscription"; break; case "JCTLinstitutional_print": echo "Journal on Centers (JCTL) Institutional Print Subscription"; break; default: echo "Journal on Centers (JCTL) subscription"; } ?> </td> <td><?php echo $originalprice2; ?></td> <td><?php echo round($itemprice2,2); ?></td> <td><?php echo $JCTLsub; ?></td> <td><?php if($JCTLrenewal){ echo "Yes";} else { echo "No";} ?></td> <?php if ($subscription_type == "institutional") { ?> <td><?php echo $tier; ?></td> <?php } ?> </tr> <?php } ?> <?php if($LCJ && $LCJ!="no"){ if($lcjprice_hidden){ $itemprice3=$lcjprice_hidden; } else { $itemprice3=$itemprice3; } ?> <tr> <td> <?php $LCJtext = $LCJ; switch ($LCJtext) { case "LCJindividual_print": echo "Learning Communities (LCJ) Individual Print Subscription"; break; case "LCJindividual_electronic": echo "Learning Communities (LCJ) Individual Electronic Subscription"; break; case "LCJinstitutional_electronic": echo "Learning Communities (LCJ) Insitutional Subscription"; break; case "LCJindividual_combo": echo "Learning Communities (LCJ) Individual Combo Subscription"; break; case "LCJinstitutional_print": echo "Learning Communities (LCJ) Institutional Print Subscription"; break; default: echo "Learning Communities (LCJ) subscription"; } ?> </td> <td><?php echo $originalprice3; ?></td> <td><?php echo round($itemprice3,2); ?></td> <td><?php echo $LCJsub; ?></td> <td><?php if($LCJrenewal){ echo "Yes";} else { echo "No";} ?></td> <?php if ($subscription_type == "institutional") { ?> <td><?php echo $tier; ?></td> <?php } ?> </tr> <?php } ?> </table> <?php if ($subscription_type == "institutional") { //$back_url="institutionalorder.php"; echo '<p>Institution details:</p><ul>'; if ($_POST['tech_contact']!='') echo "<li>Technical contact: ".$_POST['tech_contact'].'</li>'; if ($_POST['tc_phone']!='') echo "<li>Technical contact's phone: ".$_POST['tc_phone'].'</li>'; if ($_POST['tc_email']!='') echo "<li>Technical contact's email: ".$_POST['tc_email'].'</li>'; echo "<li>Network address(es):<ul><li>".str_replace($returns,'</li><li>',$_POST['net_addresses']).'</li></ul></li>'; echo '</ul>'; } else { //$back_url="individualorder.php"; } echo "<h3>Subtotal: ".$_POST['subtotal'].'</br>'; echo "Discount: ".$_POST['discount']."%".'</br>'; echo "Grand total: ".$_POST['total'].'</h3>'; echo '<p>Payment method: '.$_POST['payment_method'].'</p>'; echo '<h2>Review and submit</h2>'; echo '<p>Please review your order above to make sure it is correct, then print this page as your invoice/receipt. Finally, press the "Submit order" button below. You should receive a confirmation of your order via the email address you provided. We will begin processing it once we have received your payment. Please allow a maximum 7-10 days for you payment to be processed and for your order to be carried out.</p>'; //if ($_POST['payment_method']=='Credit card (online)') echo '<p>After you have clicked the "Submit order" button below, you will be taken to our secure payment site to complete the order. Please have your credit card ready.</p>'; echo '<table><tr>'; echo '<td> <form action="'.$back_url.'" method="post"> <input type="submit" name="redo" value="Go back and make changes">'; echo capturepostdata($_POST); echo '</form></td>'; echo '<td><form action="order_process.php" method="post"><input type="submit" name="submit" value="Submit order">'; echo capturepostdata($_POST); echo '</form></td>'; echo '</tr></table>'; include 'footer.php'; ?> I will give you an example. If the individual electronic item is ordered for each choice for a term of 2 years the price should calculate at 15%discount price x 2 for each one and then those three figures totaled (67.15*2)+(16.95*2)+(33.15*2)=234.50. That is the correct calculation and it appears on the order page as the total. When submit is hit $234.51 appears as the total on the order review page. I believe this is because it is just taking the subtotal*15% discount and not doing the calculation the same way. I need the calculation to 1. be correct in both places and 2. calculate from the first methods (the reason for this is complicated, but it has to do with tracking the individual amounts in separate places for credit card purposes.) Sorry if this sounds complicated - it is and I am confused mightily. Any help would be greatly appreciated.
-
D'oh! That's it. Thanks so much!
-
I have this code that sends two emails (among other things). When the order is see on the order review web page it looks fine and the page breaks are there. When the email is sent, the received email does not have the page breaks that should be showing on lines 76-106 of the code below. The mail does get sent and there are no error messages so I am at a loss. <?php include_once("db.php"); include_once("globals.php"); error_reporting(E_PARSE); if (isset($_POST['submit'])) { extract($_REQUEST); if($id_subcount==2){ $discount_rate=DISCOUNT_2Journals; } elseif($id_subcount==3){ $discount_rate=DISCOUNT_3Journals; }else{ $discount_rate=""; } $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $contact_name=$lastname.", ".$firstname; $emails = array(); // The receipt header is only sent to the person that placed the order $receiptHeader = <<<EndOfText <p>Your order from the Journal has been received and we will begin processing it once we have received your payment. Please allow 7-10 days for you payment to be processed and for your order to be carried out. If your order includes online access, you will receive an email containing instructions upon the completion of your order.</p> <p>Thank you and enjoy!</p> <p>Below is the information we received from your submission. If you notice any errors, please contact us immediately so we can correct them.</p> EndOfText; if ($JECT === 'JECTindividual_print') { $JECTorder = 'JECT Individual Print Subscription'; } elseif ($JECT === 'JECTindividual_electronic'){ $JECTorder = 'JECT Individual Electronic Subscription'; } elseif ($JECT === 'JECTinstitutional_electronic'){ $JECTorder = 'JECT Insitutional Subscription'; } elseif ($JECT === 'JECTindividual_combo'){ $JECTorder = 'JECT Individual Combo Subscription'; } elseif ($JECT === 'JECTinstitutional_print'){ $JECTorder = 'JECT Institutional Print Subscription'; } else { $JECTorder = 'JECT subscription'; } if ($JCTL === 'JCTLindividual_print') { $JCTLorder = 'JCTL Individual Print Subscription'; } elseif ($JCTL === 'JCTLindividual_electronic'){ $JCTLorder = 'JCTL Individual Electronic Subscription'; } elseif ($JCTL === 'JCTLinstitutional_electronic'){ $JCTLorder = 'JCTL Insitutional Subscription'; } elseif ($JCTL === 'JCTLindividual_combo'){ $JCTLorder = 'JCTL Individual Combo Subscription'; } elseif ($JCTL === 'JCTLinstitutional_print'){ $JCTLorder = 'JCTL Institutional Print Subscription'; } else { $JCTLorder = 'JCTL subscription'; } if ($LCJ === 'LCJindividual_print') { $LCJorder = 'LCJ Individual Print Subscription'; } elseif ($LCJ === 'LCJindividual_electronic'){ $LCJorder = 'LCJ Individual Electronic Subscription'; } elseif ($LCJ === 'LCJinstitutional_electronic'){ $LCJorder = 'LCJ Insitutional Subscription'; } elseif ($LCJ === 'LCJindividual_combo'){ $LCJorder = 'LCJ Individual Combo Subscription'; } elseif ($LCJ === 'LCJinstitutional_print'){ $LCJorder = 'LCJ Institutional Print Subscription'; } else { $LCJorder = 'LCJ subscription'; } $receipt = $contact_name."\n"; if ($_POST['department']!='') $receipt .= $_POST['department']."\n"; if ($_POST['institution']!='') $receipt .= $_POST['institution']."\n"; $receipt .= $_POST['address']."\n"; $receipt .= $_POST['city'].', '.$_POST['state'].' '.$_POST['zip']."\n"; $receipt .= $_POST['country']."\n"; $receipt .= $_POST['phone']."\n"; $receipt .= $_POST['email']."\n\n"; $order_details=""; $order = '<table border="1"><tr><th>Item</th><th>Base Price<br />(Single Year)</th><th>Your Price<br />(Single Year)</th>Length</th><th>Renewal?</th></tr>'; if($JECT && $JECT!="no"){ if($JECTrenewal){ $rene1="Yes";} else { $rene1="No";} $order_details .=$JECTorder."\n"; $order .= "<tr><td>".$JECTorder."</td><td>".$itemprice1."</td><td>".$jectprice_hidden."</td><td>".$JECTsub."</td><td>".$rene1."</td></tr>"; } if($JCTL && $JCTL!="no"){ if($JCTLrenewal){ $rene2="Yes";} else { $rene2="No";} $order_details .=$JCTLorder."\n"; $order .= "<tr><td>".$JCTLorder."</td><td>".$itemprice2."</td><td>".$jctlprice_hidden."</td><td>".$JCTLsub."</td><td>".$rene2."</td></tr>"; } if($LCJ && $LCJ!="no"){ $order_details .=$LCJorder."\n"; if($LCJrenewal){ $rene3="Yes";} else { $rene3="No";} $order .= "<tr><td>".$LCJorder."</td><td>".$itemprice3."</td><td>".$lcjprice_hidden."</td><td>".$LCJsub."</td><td>".$rene3."</td></tr>"; } $order .="</table>"; $receipt .= $order; $receipt .= "\n\nSubtotal: ".$subtotal; $receipt .= "\n\nDiscount: ".$discount."%"; $receipt .= "\n\nGrand total: ".$total; $receipt .= "\n\nPaying by: ".$payment_method; $message=$receiptHeader.$receipt; if($JCTLrenewal){ $JCTLrenewal="Yes";} else $JCTLrenewal="No"; if($LCJrenewal){ $LCJrenewal="Yes";} else $LCJrenewal="No"; if($JECTrenewal){ $JECTrenewal="Yes";} else $JECTrenewal="No"; $sql_insert="INSERT INTO orders SET type='$subscription_type',order_details='$order_details',subtotal='$subtotal',discount='$discount' ,grand_total='$total',payment_method='$payment_method',contact_name='$contact_name',email='$email',net_addresses='$net_addresses', department='$department',phone='$phone',address='$address',city='$city',state='$state',zip='$zip',country='$country',tech_contact='$tech_contact', tc_phone='$tc_phone',tc_email='$tc_email',tier='$tier',ip='".$_SERVER['REMOTE_ADDR']."',processed_date='".date("Y-m-d H:i:s")."', jectprice='$jectprice_hidden',jctlprice='$jctlprice_hidden',lcjprice='$lcjprice_hidden',jectrenewal='$JECTrenewal',jctlrenewal='$JCTLrenewal',lcjrenewal='$LCJrenewal', jctllength='$JCTLsub',jectlength='$JECTsub',lcjlength='$LCJsub' "; //echo $sql_insert;exit; $result=mysql_query($sql_insert); $ids=mysql_insert_id(); $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; $headers .= "From: Subscription Manager <[email protected]>" . "\r\n"; $subject="Your order has been received"; $subject1="CELTUA Journal order for $contact_name"; @mail($email, $subject, $message, $headers); @mail("[email protected]", $subject1, $message, $headers); if ($_POST['payment_method']!='Credit card (online)') { header("Location: order_thankyou.php"); } else { include 'header.php'; ?> <h1>Journal Order, continued</h1> <h2>Step 2: Make online payment</h2> <p>You will now be taken to a secure payment site to enter your credit card information and complete your online payment.</p> <p><strong>Please have your credit card ready.</strong></p> <p>Please note that if you remain on any one page of the payment site for more than about 10 minutes, even if you are working on it, it will close and send you to our "thank you" page <strong>without</strong> accepting your payment. If this happens, or if you have any other problems or questions, please contact:</p> <p>John Doe</br> Circulation Manager</br> c/o Consulting</br> <form method="post" action="https://commerce.cashnet.com/404Handler/pageredirpost.aspx?virtual=CELTJP"> <p> <?php $x = 1; // incrementing field name/number if($JECT && $JECT!="no"){ $itemcode1=$JECTitemCode; $itemprice1=$jectprice_hidden; echo "<input type='hidden' name='itemcode$x' value='$itemcode1'> <input type='hidden' name='amount$x' value='".round($itemprice1,2)."'>\n"; $x++; } if($JCTL && $JCTL!="no"){ $itemcode1=$JCTLitemCode; $itemprice1=$jctlprice_hidden; echo "<input type='hidden' name='itemcode$x' value='$itemcode1'> <input type='hidden' name='amount$x' value='".round($itemprice1,2)."'>\n"; $x++; } if($LCJ && $LCJ!="no"){ $itemcode1=$LCJitemCode; $itemprice1=$lcjprice_hidden; echo "<input type='hidden' name='itemcode$x' value='$itemcode1'> <input type='hidden' name='amount$x' value='".round($itemprice1,2)."'>\n"; } ?> <input type="hidden" name="ref1type1" value="ID"> <input type="hidden" name="ref1val1" value="<?php echo $ids; ?>"> <input type="hidden" name="ref2type1" value="STORE"> <input type="hidden" name="ref2val1" value="journals"> <input type="hidden" name="ref3type1" value="NAMEFIRST"> <input type="hidden" name="ref3val1" value="<?php echo $firstname; ?>"> <input type="hidden" name="ref4type1" value="NAMELAST"> <input type="hidden" name="ref4val1" value="<?php echo $lastname; ?>"> <input type="submit" value="Make online payment"> </p> </form> <?php include 'footer.php'; } } ?>
-
switch case returns partial results - logic issue?
learningcurve replied to learningcurve's topic in PHP Coding Help
mac_gyver, you are a genius! I can't thank you enough. Your original comment got me thinking and I was redoing it and taking out some of the "trees" but was still flailing in the forest. Your code works like a charm and does exactly what I need. This has been a great learning experience for me and hopefully improved my skills. -
switch case returns partial results - logic issue?
learningcurve replied to learningcurve's topic in PHP Coding Help
Thanks mac_gyver, I had a laugh at "too much logic". The notion of too much logic is funny, even though that is exactly the case. I can't use generics and some of the complications arrive from what I am trying to accomplish. The part of the code that contains the switch case is submitting to a payment site and it needs specific information in a specific format. It needs to have the itemcode and the item amount for each thing ordered. What is causing the monkey wrench for me is that is always has to have an item one. So if person orders a single item, that will always be item one. If they order two items, there will be an item one and an item two. Obviously then if they order all three, there will be three itemcodes and threeitem prices. The code I currently have running, for example, always has JECT as itemcode1, JCTL as itemcode2, and LCJ as itemcode3. But if they don't order JECT, then JCTL has to become itemcode1, etc. I know most of this is caused by my noobness, so forgive me if I don't understand exactly the advice you are giving. -
switch case returns partial results - logic issue?
learningcurve replied to learningcurve's topic in PHP Coding Help
Thanks for good catch! One mistake+cut and paste= a mess. I have fixed all the quotes, but my problem still remains the same. It is only outputting itemcode1 and itemprice1. -
I have an order process page that uses a switch statement. I am getting no errors and it is partially working. Case 1,2 and 3 work fine. Cases 4-7 only return itemcode1 and itemprice1. It is the correct code and amount, but it doesn't return itemcode/price 2 and/or 3. I know the data is being posted from the order page, so it has to be some flaw in how the switch is working. I am fairly new to php so would appreciate any pointers. The switch starts on line 155. <?php include_once("db.php"); include_once("globals.php"); error_reporting(E_PARSE); if (isset($_POST['submit'])) { extract($_REQUEST); if($id_subcount==2){ $discount_rate=DISCOUNT_2Journals; } elseif($id_subcount==3){ $discount_rate=DISCOUNT_3Journals; }else{ $discount_rate=""; } $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $contact_name=$lastname.", ".$firstname; $emails = array(); // The receipt header is only sent to the person that placed the order $receiptHeader = <<<EndOfText Your order from the Journal has been received and we will begin processing it once we have received your payment. Please allow 7-10 days for you payment to be processed and for your order to be carried out. If your order includes online access, you will recieve an email containing instructions upon the completion of your order. Thank you and enjoy! Below is the information we received from your submission. If you notice any errors, please contact us immediately so we can correct them. <br/><br/><br/> EndOfText; if ($JECT === 'JECTindividual_print') { $JECTorder = 'JECT Individual Print Subscription'; } elseif ($JECT === 'JECTindividual_electronic'){ $JECTorder = 'JECT Individual Electronic Subscription'; } elseif ($JECT === 'JECTinstitutional_electronic'){ $JECTorder = 'JECT Insitutional Subscription'; } elseif ($JECT === 'JECTindividual_combo'){ $JECTorder = 'JECT Individual Combo Subscription'; } elseif ($JECT === 'JECTinstitutional_print'){ $JECTorder = 'JECT Institutional Print Subscription'; } else { $JECTorder = 'JECT subscription'; } if ($JCTL === 'JCTLindividual_print') { $JCTLorder = 'JCTL Individual Print Subscription'; } elseif ($JCTL === 'JCTLindividual_electronic'){ $JCTLorder = 'JCTL Individual Electronic Subscription'; } elseif ($JCTL === 'JCTLinstitutional_electronic'){ $JCTLorder = 'JCTL Insitutional Subscription'; } elseif ($JCTL === 'JCTLindividual_combo'){ $JCTLorder = 'JCTL Individual Combo Subscription'; } elseif ($JCTL === 'JCTLinstitutional_print'){ $JCTLorder = 'JCTL Institutional Print Subscription'; } else { $JCTLorder = 'JCTL subscription'; } if ($LCJ === 'LCJindividual_print') { $LCJorder = 'LCJ Individual Print Subscription'; } elseif ($LCJ === 'LCJindividual_electronic'){ $LCJorder = 'LCJ Individual Electronic Subscription'; } elseif ($LCJ === 'LCJinstitutional_electronic'){ $LCJorder = 'LCJ Insitutional Subscription'; } elseif ($LCJ === 'LCJindividual_combo'){ $LCJorder = 'LCJ Individual Combo Subscription'; } elseif ($LCJ === 'LCJinstitutional_print'){ $LCJorder = 'LCJ Institutional Print Subscription'; } else { $LCJorder = 'LCJ subscription'; } $receipt = $contact_name."\n"; if ($_POST['department']!='') $receipt .= $_POST['department']."\n"; if ($_POST['institution']!='') $receipt .= $_POST['institution']."\n"; $receipt .= $_POST['address']."\n"; $receipt .= $_POST['city'].', '.$_POST['state'].' '.$_POST['zip']."\n"; $receipt .= $_POST['country']."\n"; $receipt .= $_POST['phone']."\n"; $receipt .= $_POST['email']."\n\n"; $order_details=""; $order = '<table border="1"><tr><th>Item</th><th>Base Price<br />(Single Year)</th><th>Your Price<br />(Single Year)</th>Length</th><th>Renewal?</th></tr>'; if($JECT && $JECT!="no"){ if($JECTrenewal){ $rene1="Yes";} else { $rene1="No";} $order_details .=$JECTorder."\n"; $order .= "<tr><td>".$JECTorder."</td><td>".$itemprice1."</td><td>".$jectprice_hidden."</td><td>".$JECTsub."</td><td>".$rene1."</td></tr>"; } if($JCTL && $JCTL!="no"){ if($JCTLrenewal){ $rene2="Yes";} else { $rene2="No";} $order_details .=$JCTLorder."\n"; $order .= "<tr><td>".$JCTLorder."</td><td>".$itemprice2."</td><td>".$jctlprice_hidden."</td><td>".$JCTLsub."</td><td>".$rene2."</td></tr>"; } if($LCJ && $LCJ!="no"){ $order_details .=$LCJorder."\n"; if($LCJrenewal){ $rene3="Yes";} else { $rene3="No";} $order .= "<tr><td>".$LCJorder."</td><td>".$itemprice3."</td><td>".$lcjprice_hidden."</td><td>".$LCJsub."</td><td>".$rene3."</td></tr>"; } $order .="</table>"; $receipt .= $order; $receipt .= "\n\nSubtotal: ".$subtotal; $receipt .= "\n\nDiscount: ".$discount."%"; $receipt .= "\n\nGrand total: ".$total; $receipt .= "\n\nPaying by: ".$payment_method; $message=$receiptHeader.$receipt; if($JCTLrenewal){ $JCTLrenewal="Yes";} else $JCTLrenewal="No"; if($LCJrenewal){ $LCJrenewal="Yes";} else $LCJrenewal="No"; if($JECTrenewal){ $JECTrenewal="Yes";} else $JECTrenewal="No"; $sql_insert="INSERT INTO orders SET type='$subscription_type',order_details='$order_details',subtotal='$subtotal',discount='$discount' ,grand_total='$total',payment_method='$payment_method',contact_name='$contact_name',email='$email',net_addresses='$net_addresses', department='$department',phone='$phone',address='$address',city='$city',state='$state',zip='$zip',country='$country',tech_contact='$tech_contact', tc_phone='$tc_phone',tc_email='$tc_email',tier='$tier',ip='".$_SERVER['REMOTE_ADDR']."',processed_date='".date("Y-m-d H:i:s")."', jectprice='$jectprice_hidden',jctlprice='$jctlprice_hidden',lcjprice='$lcjprice_hidden',jectrenewal='$JECTrenewal',jctlrenewal='$JCTLrenewal',lcjrenewal='$LCJrenewal', jctllength='$JCTLsub',jectlength='$JECTsub',lcjlength='$LCJsub' "; //echo $sql_insert;exit; $result=mysql_query($sql_insert); $ids=mysql_insert_id(); $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; $headers .= "From: [email protected] <[email protected]>" . "\r\n"; $subject="Your order has been received"; $subject1="CELTUA Journal order for $contact_name"; @mail($email, $subject, $message, $headers); @mail("[email protected]", $subject1, $message, $headers); if ($_POST['payment_method']!='Credit card (online)') { header("Location: order_thankyou.php"); } else { include 'header.php'; ?> <h1>Journal Order, continued</h1> <h2>Step 2: Make online payment</h2> <p>You will now be taken to a secure payment site to enter your credit card information and complete your online payment.</p> <p><strong>Please have your credit card ready.</strong></p> <p>Please note that if you remain on any one page of the payment site for more than about 10 minutes, even if you are working on it, it will close and send you to our "thank you" page <strong>without</strong> accepting your payment. If this happens, or if you have any other problems or questions, please contact:</p> <p>Circulation Manager</br> Monroe, OH 45050</br> United States</br></br> <form method="post" action="https://commerce.cashnet.com/404Handler/pageredirpost.aspx?virtual=CELTJP"> <p> <?php switch(true) { case (($JECT && $JECT!="no") && ($JCTL && $JCTL!="yes") && ($LCJ && $LCJ!="yes")): $itemcode1=$JECTitemCode; $itemprice1=$jectprice_hidden; ?> <input type='hidden' name='itemcode1' value=<?php echo $itemcode1; ?>> <input type='hidden' name='amount1' value="<?php echo round($itemprice1,2); ?>"> <?php break; case (($JECT && $JECT!="yes") && ($JCTL && $JCTL!="no") && ($LCJ && $LCJ!="yes")): $itemcode1=$JCTLitemCode; $itemprice1=$jctlprice_hidden; ?> <input type='hidden' name='itemcode1' value=<?php echo $itemcode1; ?>> <input type='hidden' name='amount1' value="<?php echo round($itemprice1,2); ?>"> <?php break; case (($JECT && $JECT!="yes") && ($JCTL && $JCTL!="yes") && ($LCJ && $LCJ!="no")): $itemcode1=$LCJitemCode; $itemprice1=$lcjprice_hidden; ?> <input type='hidden' name='itemcode1' value=<?php echo $itemcode1; ?>> <input type='hidden' name='amount1' value="<?php echo round($itemprice1,2); ?>"> <?php break; case (($JECT && $JECT!="no") && ($JCTL && $JCTL!="no") && ($LCJ && $LCJ!="yes")): $itemcode1=$JECTitemCode; $itemprice1=$jectprice_hidden; $itemcode2=$JCTLitemCode; $itemprice2=$jctlprice_hidden; ?> <input type='hidden' name='itemcode1' value=<?php echo $itemcode1; ?>> <input type='hidden' name='amount1' value=<?php echo round($itemprice1,2); ?>"> <input type='hidden' name='itemcode2' value=<?php echo $itemcode2; ?>> <input type='hidden' name='amount2' value=<?php echo round($itemprice2,2); ?>"> <?php break; case (($JECT && $JECT!="no") && ($JCTL && $JCTL!="yes") && ($LCJ && $LCJ!="no")): $itemcode1=$JECTitemCode; $itemprice1=$jectprice_hidden; $itemcode2=$LCJitemCode; $itemprice2=$lcjprice_hidden; ?> <input type='hidden' name='itemcode1' value=<?php echo $itemcode1; ?>> <input type='hidden' name='amount1' value=<?php echo round($itemprice1,2); ?>"> <input type='hidden' name='itemcode2' value=<?php echo $itemcode2; ?>> <input type='hidden' name='amount2' value=<?php echo round($itemprice2,2); ?>"> <?php break; case (($JECT && $JECT!="yes") && ($JCTL && $JCTL!="no") && ($LCJ && $LCJ!="no")): $itemcode1=$JCTLitemCode; $itemprice1=$jctlprice_hidden; $itemcode2=$LCJitemCode; $itemprice2=$lcjprice_hidden; ?> <input type='hidden' name='itemcode1' value=<?php echo $itemcode1; ?>> <input type='hidden' name='amount1' value=<?php echo round($itemprice1,2); ?>"> <input type='hidden' name='itemcode2' value=<?php echo $itemcode2; ?>> <input type='hidden' name='amount2' value=<?php echo round($itemprice2,2); ?>"> <?php break; case (($JECT && $JECT!="no") && ($JCTL && $JCTL!="no") && ($LCJ && $LCJ!="no")): $itemcode1=$JECTitemCode; $itemprice1=$jectprice_hidden; $itemcode2=$JCTLitemCode; $itemprice2=$jctlprice_hidden; $itemcode3=$LCJitemCode; $itemprice3=$lcjprice_hidden; ?> <input type='hidden' name='itemcode1' value=<?php echo $itemcode1; ?>> <input type='hidden' name='amount1' value=<?php echo round($itemprice1,2); ?>"> <input type='hidden' name='itemcode2' value=<?php echo $itemcode2; ?>> <input type='hidden' name='amount2' value=<?php echo round($itemprice2,2); ?>"> <input type='hidden' name='itemcode3' value=<?php echo $itemcode3; ?>> <input type='hidden' name='amount3' value=<?php echo round($itemprice3,2); ?>"> <?php break; } ?> <input type="hidden" name="ref1type1" value="ID"> <input type="hidden" name="ref1val1" value="<?php echo $ids; ?>"> <input type="hidden" name="ref2type1" value="STORE"> <input type="hidden" name="ref2val1" value="journals"> <input type="hidden" name="ref3type1" value="NAMEFIRST"> <input type="hidden" name="ref3val1" value="<?php echo $firstname; ?>"> <input type="hidden" name="ref4type1" value="NAMELAST"> <input type="hidden" name="ref4val1" value="<?php echo $lastname; ?>"> <input type="submit" value="Make online payment"> </p> </form> <?php include 'footer.php'; } } ?>
-
Need help with IFELSE doing two things
learningcurve replied to learningcurve's topic in PHP Coding Help
I fixed line 9 ($JCTLitemCode), and I am now getting returns on both itemcode 1 and 2, but item 1 is duplicating. Here is the result: <input type='hidden' name='itemcode1' value=5612CW> <input type='hidden' name='amount1' value=71.1"> <input type='hidden' name='itemcode1' value=5612CW> <input type='hidden' name='amount1' value=71.1"> <input type='hidden' name='itemcode2' value=9113CW> <input type='hidden' name='amount2' value=17.96"> Why is itemcode1 repeating? I know it is obvious, just not to me. Thanks for any help. -
HI, I am fairly new to PHP and I am working on a complicated ifelse statement. I am getting the first part of it to work (i.e. showing itemcode1 and itemvalue1, but I can't get it to echo the item code2/value2. I know it is because of incorrect syntax in lines 3-14, but I can't figure out how to make it work. I have tried to research it, but nothing I can find speaks to having two outcomes. Thanks ahead for any help. }elseif(($JECT && $JECT!="no") && ($JCTL && $JCTL!="no") && ($LCJ && $LCJ!="yes")) { $itemcode1=$JECTitemCode; if($jectprice_hidden){ $itemprice1=$jectprice_hidden; } else{ $itemprice1=$itemprice1; } $itemcode2=JCTLitemCode; if($jctlprice_hidden){ $itemprice2=$jctlprice_hidden; } else{ $itemprice2=$itemprice2; } ?> <input type='hidden' name='itemcode1' value=<?php echo $itemcode1; ?>> <input type='hidden' name='amount1' value=<?php echo round($itemprice1,2); ?>"> <input type='hidden' name='itemcode2' value=<?php echo $itemcode2; ?>> <input type='hidden' name='amount2' value=<?php echo round($itemprice2,2); ?>"> <?php } ?>
-
I have this form code, written by another person. Currently it looks to see if the first value($JECT) is empty. If not it creates an itemcode1. If it is empty, it skips to the next value($JCTL) and does the same, except it makes it itemcode2. I need for the first one($JECT) to be itemcode1 if not empty, the second($JCTL) to be itemcode1 if the first is empty and itemcode2 if it is not. The same for the third(LCJ) -item 1, 2, or 3 depending on the values of the others. So basically, I always need to have an itemcode1 for processing and possibly an itemcode2 or 3. I hope this is clearer than it sounds to me. Thanks for any help! <form method="post" action="URLHERE"> <p> <?php if($JECT && $JECT!="no"){ $itemcode1=$JECTitemCode; if($jectprice_hidden){ $itemprice1=$jectprice_hidden; } else { $itemprice1=$itemprice1; } ?> <input type='hidden' name='itemcode1' value=<?php echo $itemcode1; ?>> <input type='hidden' name='amount1' value="<?php echo round($itemprice1,2); ?>"> <?php } ?> <?php if($JCTL && $JCTL!="no"){ $itemcode2=$JCTLitemCode; if($jctlprice_hidden){ $itemprice2=$jctlprice_hidden; } else { $itemprice2=$itemprice1; } ?> <input type='hidden' name='itemcode2' value=<?php echo $itemcode2; ?>> <input type='hidden' name='amount2' value="<?php echo round($itemprice2,2); ?>"> <?php } ?> <?php if($LCJ && $LCJ!="no"){ $itemcode3=$LCJitemCode; if($lcjprice_hidden){ $itemprice3=$lcjprice_hidden; } else { $itemprice3=$itemprice1; } ?> <input type='hidden' name='itemcode3' value=<?php echo $itemcode3; ?>> <input type='hidden' name='amount3' value="<?php echo round($itemprice3,2); ?>"> <?php } ?> <input type="hidden" name="ref1type1" value="ID"> <input type="hidden" name="ref1val1" value="<?php echo $ids; ?>"> <input type="hidden" name="ref2type1" value="STORE"> <input type="hidden" name="ref2val1" value="journals"> <input type="hidden" name="ref3type1" value="NAMEFIRST"> <input type="hidden" name="ref3val1" value="<?php echo $firstname; ?>"> <input type="hidden" name="ref4type1" value="NAMELAST"> <input type="hidden" name="ref4val1" value="<?php echo $lastname; ?>"> <input type="submit" value="Make online payment"> </p> </form>
-
javascript stopWithAlert not working with html query string
learningcurve replied to learningcurve's topic in Javascript Help
Problem resolved! At one point it enters invited as a hidden value so all I did was change the stop alert line to: if (realForm.type.value != "invited" && realForm.infocheck.checked == false) {return stopWithAlert("Please read and agree to verification statement.", realForm.infocheck);} Works like a charm! -
I have a form I am using. You can access this form from two different urls. url1.com/form.php and url1.com/form.php?invited Depending on the url used to access the form, I have a section either show or not show. The code for this is: <?php if (!$invited) echo '<p><strong><input type="checkbox" id="infocheck" name="infocheck" value="Yes" > Verification Statement: "I verify that I have followed the proposal guidelines above and that my proposal includes citations of relevant literature and a reference list in APA format, a discussion of evidence of learning outcomes, and a description of how the session will be run."</strong></p>'; ?> What I am having trouble with is a stop alert for verification in my javascript. I currently have: if (realForm.infocheck.checked == false) {return stopWithAlert("Please read and agree to verification statement.", realForm.infocheck);} How do I tell this to only do this if that section of the form is available and checked? When visible it has to be checked to proceed, when not visible (ie for an invited person with ?invited in the query string, I don't want it to even check. Javascript is not my strong point. Thanks for any help.
-
URL variable to set style.css and template directory
learningcurve replied to learningcurve's topic in Third Party Scripts
Thanks for the great feedback. I learn so much everytime I post here. I will work on my code some more. -
I have a page that is accessed with this URL: http://celt.muohio.edu/lillycon/oldpresenters.php?year=2010 (year could equal any of course) and it lists the presenters based on the year variable. That is working fine. I also want it to load the style.css, the header and the footer based on the year chosen. That is not working. Here is the code I currently have. I didn't write the original code. I have tried TEMPLATEDIR and TEMPLATEURL but feel like I am missing something obvious. I am still learning PHP so I am definitely slow on the problem solving end. <?php require 'main_include.php'; $year = mysql_real_escape_string($_GET['year']); $TEMPLATEDIR = "http://www.units.muohio.edu/lillycon/old/$year"; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Lilly Conference</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="http://celt.muohio.edu/favicon.png" rel="shortcut icon"> <style type="text/css"> @import url("style.css"); </style> </head> <body> <?php $type = "featured"; $includeFile = file_get_contents("lillyheader.php"); echo $includeFile; // Builds a list of all presenters and their sessions; ECHOs each individual entry for faster to-browser dumping in these long lists. echo "<h1>Lilly $useyear Presenters and Topics</h1>"; $bigList = presentersForYear($year,$type); if (count($bigList)>0) { foreach ($bigList as $value) { echo general($value,$year); } } else { echo "<h4>No $type sessions have been confirmed yet, but please check back soon.</h4>"; } if (isset($_GET['presenter'])) { echo longbio($_GET['presenter'],$useyear); } else if (isset($_GET['session'])) { echo sessAbstract($_GET['session'],$useyear); } else if (isset($_GET['type'])) { echo general_lister($_GET['type'],$useyear); } else { echo general_lister('featured',$year); } $includeFile = file_get_contents("lillyfooter.php"); echo $includeFile; ?> </body> </html>
-
I am working with an old script someone else wrote that pulls data from this year as well as prior year. A global is set: $thisyear = '2012' According to my understanding this code: <?php require 'main_include.php'; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Conference</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="http://conferencecenter.edu/favicon.png" rel="shortcut icon"> <style type="text/css"> @import url("http://www.conferencecenter.edu/conference/style.css"); </style> </head> <body> <?php $includeFile = file_get_contents("http://www.conferencecenter.edu/conference/header.php"); echo $includeFile; // Builds a list of all presenters and their sessions; ECHOs each individual entry for faster to-browser dumping in these long lists. function general_lister($type, $year='') { global $thisyear,$splitchar; if ($year=='') $year = $thisyear; if ($type=='featured') { echo "<h1>Conference $year Presenters and Topics</h1>"; } else { echo "<h1>Conference $year Contributed Presenters and Topics</h1>"; } // echo '<p><a href="presenters.php?type=featured&year='.$year.'">Featured Presenters</a> • <a href="presenters.php?type=contributed&year='.$year.'">Contributed Papers</a></p>'; echo '<p>Notice: the information presented here is subject to change without notice.</p>'; $bigList = presentersForYear($year,$type); if (count($bigList)>0) { foreach ($bigList as $value) { echo general($value,$year); } } else { echo "<h4>No $type sessions have been confirmed yet, but please check back soon.</h4>"; } } if (isset($_GET['presenter'])) { echo longbio($_GET['presenter'],$useyear); } else if (isset($_GET['session'])) { echo sessAbstract($_GET['session'],$useyear); } else if (isset($_GET['type'])) { echo general_lister($_GET['type'],$useyear); } else { echo general_lister('featured',$year); } $includeFile = file_get_contents("http://conferencecenter.edu/conference/footer.php"); echo $includeFile; ?> </body> </html> should pull the current data with the url being set at conferencecenter.edu/conference/presenters.php and pull the prior year with this URL: conferencecenter.edu/conference/presenters.php?year=2010 (or any other year). It doesn't work. No matter what the URL it only pulls current 2012 data. I know this code has javascript in it - old javascript - and I just can't figure it out let alone where the problem is. Here is some code from the main include file: <?php // This PHP script contains routines used by the database-driven pages of the conference website. // First let's set up some global values: global $keywordspage,$presenterspage,$calendarpage,$splitchar,$useyear,$returns; require_once '/www/universal.php'; require_once 'prices_etc.php'; require_once 'formatting_functions.php'; require_once 'db_functions.php'; $splitchar = "\n"; // This is the delimiter character for use in lists $returns = array("\r\n","\r","\n"); // Break characters; generally used to convert all these to single standard one if (!isset($_GET['year']) || $_GET['year']==$thisyear) { $useyear = $thisyear; $templateDIR = "http://www.conferencecenter.edu/conference"; } else { $useyear = mysql_real_escape_string($_GET['year']); $templateDIR = "http://www.conferencecenter.edu/conference/old/$useyear"; } $calendarpage = 'schedule.php'; $presenterspage = 'presenters.php'; $keywordspage = 'keywords.php'; function pWrap($string) { if (strpos(strtolower($string),'<p')===FALSE) $string = "<p>$string</p>"; return $string; } function sortSessions($sessionsArray,$fieldName) { if (count($sessionsArray)<2) return $sessionsArray; $qString = 'SELECT `id` FROM `sessions` WHERE'; $count = 0; foreach ($sessionsArray as $session) { $session = mysql_real_escape_string($session); if ($count!=0) $qString .= ' OR'; $qString .= " `id`='$session'"; ++$count; } $fieldName = mysql_real_escape_string($fieldName); $qString .= " ORDER BY `$fieldName`;"; $result = mysql_query($qString); $output = array(); while ($row = mysql_fetch_assoc($result)) { $output[] = $row['id']; } return $output; } function presentersForYear($year, $type) { // Type can be "all" for all presenters global $splitchar; if ($type=='all') $type = "invited' OR type='contributed"; else $type = mysql_real_escape_string($type); $year = mysql_real_escape_string($year); $bigList = array(); $result = mysql_query("SELECT `name` FROM `presenters` WHERE `type`='$type' AND `hidden`!='yes';"); while ($row = mysql_fetch_assoc($result)) { if (inYear($row['name'],$year)) $bigList[] = $row['name']; } $bigList = array_unique($bigList); sort($bigList); return $bigList; } Any help would be greatly appreciated.
-
Hi, I am installing Oracle Linux as a virtual local test server using VMWare Fusion on an OS Lion machine. All seems to be going well, except I am getting one error in the php log that I can't figure out. I know it has something to do with it being a virtual machine without a domain name, but I don't know what. I am still very new to learning PHP, etc. Here is the error from the log file: [error] avahi_entry_group_add_service_strlst ("localhost") failed: Invalid host name Httpd/conf/httpd.conf: ServerName localhost Here is what I have in my /etc/hosts file: 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 Any help would be appreciated.
-
Hi, I was trying to mark a topic solved and could not remember how so I thought I would do a search in the help forum. I am getting this error, no matter what parts of the forum I search: An Error has occurred You are not allowed to search for posts in this forum. Also, the solved button does not seem to appear anywhere on my page. Thanks!
-
Adding all to drop down populated by db query
learningcurve replied to learningcurve's topic in PHP Coding Help
I was thinking the same thing on my way home but couldn't remember what the exact word was - thought I was going to have to pull out a book. That did it! Thank you so much for your help - I now have a great working query!! (and much more knowledge about PHP - I feel like I am finally staring to "get" it). Lisa -
Adding all to drop down populated by db query
learningcurve replied to learningcurve's topic in PHP Coding Help
Okay... Very, very, very close... it is perfect except it returns all possible choices every time they occur instead of just once. For example, the column in the db contains red, blue and green. I want red, blue, green and all to show up in the drop down options. What is showing up is red 29 times (or however many times it occurs in the db), blue 15 times, green 12 and all once - you get the idea. The good news is that whatever i select works and returns results. So... I kinda feel like I am close but no cigar. I do appreciate your help and guidance in getting me this far - you are a gem! Any more nuggets of wisdom? -
Adding all to drop down populated by db query
learningcurve replied to learningcurve's topic in PHP Coding Help
Sorry, doesn't work. I don't get an error message and the form only displays on the page until it hits what should be the first drop down. I am going through your code but I am enough of a newbie that I don't get all of it. Thanks for the real escape string though! -
Adding all to drop down populated by db query
learningcurve replied to learningcurve's topic in PHP Coding Help
Thanks, but I think I was unclear. I want to add All as a choice in the drop down. So they could pick all for drop down 1 and still have a choice for the second drop down and vice versa. Not just a generic ALL. Thanks for the good answer though. -
I have a query with two drop down boxes populated from the db through a query. Everything is working great. I now want to add an option for ALL. Not sure how I would do that with the way I have populated the boxes. Thanks! <html> <head> </head> <body> <?php //db connections or error returns $connect = mysql_connect(DELETED); if (!$connect) { exit('<p>Unable to connect to the server at this time.</p>'); } mysql_select_db("surveys"); if (!mysql_select_db("surveys")) { exit ('<p>Unable to locate the database at this time.</p>'); } //if the "submit" variable does not exist, the form has not been submitted - display initial page if (!isset($_POST['submit'])) { //form ?> <form name="sgid" id="sgid" method="post" action="sgidsurveyquery.php"> <h1>SGID Satisfaction Survey Results</h1> <h2>Results can be filtered by evaluation party and semester/year given.</h2></br> Please choose: <?php //pull evaluator drop down choices from db as array $query="SELECT q1 FROM surveys.SGID_satisfaction"; $result=mysql_query($query); $options=""; while ($row=mysql_fetch_array($result)){ $evaluator=$row("q1"); $options.="<OPTION VALUE=>$evaluator</option"; } ?> <select name="evaluator"> <option value=0> <? echo $options?> </select> for <?php //pull date drop down choices from db as array $query="SELECT q2 FROM surveys.SGID_satisfaction"; $result=mysql_query($query); $options=""; while ($row=mysql_fetch_array($result)){ $date=$row("q2"); $options.="<OPTION VALUE=>$date</option"; } ?> <select name="date"> <option value=0> <? echo $options?> </select> <input type="submit" name ="submit" value="Show Results"> </form> <?php } else { //display results print"<h2>SGID Satisfaction Survey Results</h2><br/>"; $evaluator=$_POST['evaluator']; $date=$_POST['date']; //run query $query = "SELECT q1, q2, q3, q4, q5 FROM surveys.SGID_satisfaction WHERE q1='$evaluator' AND q2= '$date' ORDER BY created"; echo "<h3>Results of SGID Satisfaction Survey performed by $evaluator during $date</h3></br>"; //display number of records returned $result = mysql_query ($query) or die(mysql_error()); $num_rows = mysql_num_rows($result); echo "Your query returned $num_rows responses."; //Start a table print "<table CELLPADDING=10 border =1 >"; print "<tr>"; print "<th style='width:150px'>Which organization did your SGID?</th>"; print "<th style='width:100px'>Please specify the semester and year the SGID was done.</th>"; print "<th style='width:300px'>What about this service was helpful for your teaching?</th>"; print "<th style='width:300px'>What about this service could be improved to support your teaching?</th>"; print "<th style='width:300px'>Would you be willing for us to contact you later about what, if anything, you have changed and how that has affected student learning?</th>"; print "</tr>"; while ($row = @mysql_fetch_array($result)) { print "<table CELLPADDING=10 border = 1>"; print "<tr>"; print "<td style='width:150px'>".$row['q1']."</td>"; print "<td style='width:100px'>".$row['q2']."</td>"; print "<td style='width:300px'>".$row['q3']."</td>"; print "<td style='width:300px'>".$row['q4']."</td>"; print "<td style='width:300px'>".$row['q5']."</td>"; print "</tr>"; print "</table>"; } //close results mysql_close(); } ?> </body> </html>