SeanWoods Posted March 28, 2009 Share Posted March 28, 2009 I will be honest. I am totally new to PHP but have been getting along with help from great people on these forums. I am having trouble transferring the options that someone selects from the drop down boxes on this page: http://grammarperfection.com/checkout.php and having these options populate in the coordinating places on this page: http://grammarperfection.com/confirmorder.php In case you need to look at the php for the first page (http://grammarperfection.com/checkout.php), here it is: <? $serv = $_GET['serv']; // retrieves the data and creates a variable called $serv $words = $_GET['words']; // as above $servvalue = $serv; // creating a value to go in the drop down box.. if($serv == 1) { $serv = "Standard - 3 Day/72 Hour Return - $5.00 Per Page"; $opt1 = ' selected="selected"'; } if($serv == 2) { $serv = "Expedite - 2 Day/48 Hour Return - $7.50 Per Page"; $opt2 = ' selected="selected"'; } if($serv == 3) { $serv = "Overnight - 1 Day/24 Hour Return - $9.00 Per Page"; $opt3 = ' selected="selected"'; } ?> <select name="select"> <option value="1"<?php echo $opt1?>>Standard - 3 Day/72 Hour Return - $5.00 Per Page</option> <option value="2"<?php echo $opt2?>>Expedite - 2 Day/48 Hour Return - $7.50 Per Page</option> <option value="3"<?php echo $opt3?>>Overnight - 1 Day/24 Hour Return - $9.00 Per Page</option> <input type="text" name="txtWordCount" size="20" maxlength="20" value="<? echo $words; ?>"> Here is the complete HTML for the page I am having trouble with: <!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"><!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="shortcut icon" href="Images/gpfavicon.ico"/> <!-- InstanceBeginEditable name="doctitle" --> <title>Editing, Proofreading and Grammar Checking Service - Grammar Perfection</title> <!-- InstanceEndEditable --> <meta name="keywords" content="service,editing,english grammar,proofreading,apa style,writing help,editorial services,essay editing,grammar help,proofread,academic paper,proofreading english,proofreading online,business editorial,proofreading service,proofreading services,business editor,write,college application,apa style,college applications,resume,editorial,resumes,edit document,writing,cover letter,cover letters,editing service,resumes cover letters,writing,apa style,apa,online editor,cbe style,cbe,proofreading essay,english,mla style,mla,editing services,chicago style, financial document,grammer help,financial documents,english writing,academic papers,copy editor,business proofreading,mla style,edit,editor,english grammer,essay help,"> <meta name="description" content="Professional proofreading and editing service. We edit essays, resumes, and other forms of writing. Let our editing specialists proofread your writing today."> <!--GrammarPerfection.com: writing editing apa style proofreading writing editors english grammar proofreading apa style editing writing apa style editors english grammar mla style writing editing apa style editing mla style proofreading writing english grammar mla style etc.--> <style type="text/css"> <!-- --> </style> <link href="CSS/layout.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- body { background-image: url(Images/background.gif); } .style1 { font-size: 1px; color: #CCCCCC; } --> </style> <script type="text/javascript"> <!-- function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } //--> </script> <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --> </head> <body> <div id="logo"><a href="index.html"><img src="Images/grammar-perfection-proofreading-and-editing-service.jpg" alt="Grammar Perfection we catch what spell check misses" width="620" height="172" /></a></div> <div id="navigation"><a href="index.html">Home</a> | <a href="submitdocument.html">Submit Document</a> | <a href="guarantee.html">100% Guarantee</a> | <a href="examplesofwork.html">Example of Our Work</a> | <a href="faq.html">FAQ</a> | <a href="recommendafriend.html">Get 1/2 Off Your Next Order</a> | <a href="cost.html">Cost</a></div> <div id="wrapper"> <div id="bodyArea"> <div id="left"> <h5><a href="index.html"><img src="Images/grammar-perfection-home-icon.jpg" alt="Home for proofreading and editing "class="img" longdesc="../index.html" /><br /> Home</a></h5> <h5><a href="submitdocument.html"><img src="Images/submit-your-document-for-proofreading-editing-icon.jpg" alt="Submit your document for editing and proofreading" name="icons" id="icons" /><br /> Submit Document</a></h5> <h5><a href="guarantee.html"><img src="Images/satisfaction-guaranteed-icon.jpg" alt="We guarantee our proofreading and editing or your money back!" name="icons" id="icons" /><br /> 100% Guarantee!</a></h5> <h5><a href="examplesofwork.html"><img src="Images/example-of-what-grammar-perfection-does.jpg" alt="View an example of our proofreading and editing" name="icons" id="icons" /><br /> Example of Our Work</a></h5> <h5><a href="faq.html"><img src="Images/frequently-asked-questions-about-proofreading-editing.jpg" alt="Frequently asked questions about our proofreading and editing service" name="icons" id="icons" /><br /> Frequently Asked Questions</a></h5> <h5><a href="recommendafriend.html"><img src="Images/proofreding-editing-discount.jpg" alt="Get half off your next proofreading and editing service" name="icons" id="icons" /><br /> Get 1/2 Off Your Next Order!</a></h5> <h5><a href="cost.html"><img src="Images/cost-for-proofreading-editing-service.jpg" alt="How much does it cost for proofreading and editing" name="icons" id="icons" /><br /> How Much Does it Cost?</a></h5> </div> <div id="right"> <!-- InstanceBeginEditable name="Main Area" --> <h1>Confirm Order</h1> <table width="620" border="0" align="center" cellpadding="2" cellspacing="2"> <tr> <td class="pagetitle" align="left" nowrap="nowrap" height="20"> Confirm Order </td> </tr> <tr> <td class="pagetext" valign="top" width="650"><table border="1" cellpadding="4" cellspacing="0"> <tr> <td class="pagetext"><b>Service Option</b> </td> <td class="pagetext"> </td> </tr> <tr> <td class="pagetext"><b>Word Count/Pages</b> </td> <td class="pagetext"> </td> </tr> <tr> <td class="pagetext"><b>Cost</b> </td> <td class="pagetext"> </td> </tr> <tr> <td class="pagetext"><b>Level Of Work</b> </td> <td class="pagetext"> </td> </tr> <tr> <td class="pagetext"><b>Writing Format</b> </td> <td class="pagetext"> </td> </tr> <tr> <td class="pagetext"><b>Document Status</b> </td> <td class="pagetext"> You will be asked to e-mail your document to <a href="mailto:[email protected]?subject=Proof My Document: Document Attached">[email protected]</a> AFTER submitting your payment. </td> </tr> </table> <table border="0"> <tr> <td align="middle" valign="top"><input type="button" id="btnEdit" value="Edit Information" onclick="history.back();" /> </td> <td><!-- Begin PayPal Code --> <!-- Order Options --> <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="add" value="1" /> <input type="hidden" name="cmd" value="_cart" /> <input type="hidden" name="business" value="[email protected]" /> <input type="hidden" name="item_name" value="Standard - 3 Day/72 Hour Return - $5.00 Per Page x 2 pages" /> <input type="hidden" name="item_number" value="STD" /> <input type="hidden" name="amount" value="$10.00" /> <input type="hidden" name="currency_code" value="USD" /> <input type="hidden" name="bn" value="PP-ShopCartBF" /> <input type="hidden" name="on0" value="Level of Work" /> <input type="hidden" name="os0" value="High School" /> <input type="hidden" name="on1" value="Writing Format" /> <input type="hidden" name="return" value="http://www.proofmydoc.com/send_document.html" /> <input type="hidden" name="os1" value="MLA" /> <!-- Display Options --> <!--<input type="hidden" name="cpp_header_image" value="http://www.proofmydoc.com/images/main_logo.gif"> --> <input type="submit" value="Proceed to Secure Payment with PayPal" name="btnPayPal" alt="Make payments with PayPal - it's fast, free and secure!" /> </form> <!-- End PayPal Code --> </td> </tr> </table></td> </tr> </table> <p> </p> <!-- InstanceEndEditable --></div> <div id="footer"> <p><a href="customerservice.html">Customer Service</a> | <a href="links.html">Links</a> | <a href="employment.html">Employment</a></p> </div> </div> </div> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-3295634-3"); pageTracker._trackPageview(); } catch(err) {}</script> </body> <!-- InstanceEnd --></html> Link to comment https://forums.phpfreaks.com/topic/151465-trouble-transferring-data-from-drop-down-box-to-next-page/ Share on other sites More sharing options...
Kieran Menor Posted March 28, 2009 Share Posted March 28, 2009 First of all, since your form method is "post", you need to use the $_POST variable, rather than the $_GET variable. Link to comment https://forums.phpfreaks.com/topic/151465-trouble-transferring-data-from-drop-down-box-to-next-page/#findComment-795579 Share on other sites More sharing options...
SeanWoods Posted March 28, 2009 Author Share Posted March 28, 2009 Am I on the right track for the part that goes above the HTML? <? $serv = $_POST['serv']; // retrieves the data and creates a variable called $serv $servvalue = $POST; // creating a value to go in the drop down box.. if($serv == 1) { $serv = "Standard - 3 Day/72 Hour Return - $5.00 Per Page"; $opt1 = ' selected="selected"'; } if($serv == 2) { $serv = "Expedite - 2 Day/48 Hour Return - $7.50 Per Page"; $opt2 = ' selected="selected"'; } if($serv == 3) { $serv = "Overnight - 1 Day/24 Hour Return - $9.00 Per Page"; $opt3 = ' selected="selected"'; } ?> Link to comment https://forums.phpfreaks.com/topic/151465-trouble-transferring-data-from-drop-down-box-to-next-page/#findComment-795599 Share on other sites More sharing options...
SeanWoods Posted March 28, 2009 Author Share Posted March 28, 2009 I was able to make the options from the 1st drop down box transfer to the next page. This was accomplished by inputting this entire code <?php $serviceOptions = array( 1 => "Standard - 3 Day/72 Hour Return - $5.00 Per Page", 2 => "Expedite - 2 Day/48 Hour Return - $7.50 Per Page", 3 => "Overnight - 1 Day/24 Hour Return - $9.00 Per Page" ); // note that $_POST index must exactly match name of form element: $serviceSelection = (int) $_POST['select']; // filter input to make sure it's an integer if(!isset($serviceOptions[$serviceSelection])) { $serviceSelection = 1; // set a default value in case of invalid selection } // create pre-filled select element: echo "<select name='select'>\n"; foreach($serviceOptions as $key => $value) { $selected = ''; if($key == $serviceSelection) // same as what user selected { $selected = " selected='selected'"; } echo "<option value='$key'$selected>$value</option>\n"; } echo "</select>\n"; ?> in the table where I want the info to appear. The only thing is that I would rather it show only the option selected from the previous page, not another drop down box. I would like this to be more of a confirm page, rather than to allow the user to make selections again. I am also having trouble modifying the code to work for my other 2 drop down boxes. I am not sure if I add to the array, or to re-write the array or what. I tried copying the entire code in the spot where the input should appear for the 2nd drop down box (with changing the options to match this drop down box rather than the original) but that didn't work. Do I make a new array? Or add onto this one? Link to comment https://forums.phpfreaks.com/topic/151465-trouble-transferring-data-from-drop-down-box-to-next-page/#findComment-795760 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.