racercam Posted October 19, 2010 Share Posted October 19, 2010 I'm trying to create a web ' order form ' basically i've been trying to miss match different guides online and im very confused! Can someone fix it so it would e-mail me the data I have a PHP enabled web host / server... all this is very new to me and its a complex form i need Thanks In advance! this is the code I have : </head> <body> <form> <form method="POST" action="thanks.php"> <table border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#3E55A7" bgcolor="#C7CFE9"> <tr> <td colspan="10" bgcolor="3e55a7" class="style9"><div align="center">CUSTOMER ORDER FORM </div> <div align="center"></div></td> </tr> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td colspan="10" bgcolor="#C7CFE9"><div align="center"></div></td> </tr> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td colspan="4" class="style17"><strong>NAME <input name="custname" type="text" class="style17" tabindex="1" size="53"> </strong></td> <td width="86"> </td> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td colspan="4" class="style17"><strong>ADDRESS<span class="style15"> <textarea name="custadd" cols="50" class="style17" tabindex="2"></textarea> </span></strong></td> <td class="style15"> </td> </tr> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td height="24" colspan="4" class="style17">TOWN<span class="style15"> <input name="custtown" type="text" class="style17" id="custtown" tabindex="3" size="53"> </span></td> <td class="style15"> </td> </tr> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td height="24" colspan="4" class="style17"><strong>POSTCODE<span class="style15"> <input name="custcode" type="text" class="style17" id="custcode" tabindex="3.5" size="53"> </span></strong></td> <td class="style15"> </td> </tr> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td height="27" colspan="4" class="style17"><strong>PHONE<span class="style15"> <input name="custphone" type="text" class="style17" id="custphone" tabindex="4" size="53"> </span></strong></td> <td class="style15"> </td> </tr> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td height="42" colspan="4" class="style17"><strong>EMAIL<span class="style15"> <input name="re_Email" type="text" class="style17" id="re_Email" tabindex="5" size="53"> </span></strong></td> <td class="style15"> </td> </tr> <tr bgcolor="#F5F4FD"> <td width="94">Item Number </td> <td width="86">Page Number </td> <td width="84">Product Code </td> <td width="215">Description</td> <td>Price</td> <td width="62">QTY</td> <td width="57">Total</td> </tr> <tr bgcolor="#F5F4FD"> <td>1</td> <td><input name="pg2" type="text" class="style17" id="pg2" tabindex="13" size="8"></td> <td><input name="pg2" type="text" class="style17" id="pg2" tabindex="13" size="8"></td> <td><input name="cd2" type="text" class="style17" id="cd2" tabindex="14" size="9"></td> <td><input name="desc2" type="text" class="style17" id="desc2" tabindex="15" size="12"></td> <td bordercolor="#3E55A7"><input name="price2" type="text" class="style17" id="price2" tabindex="16" size="6"></td> <td><input name="qty2" type="text" class="style17" id="qty2" tabindex="17" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>2</td> <td><input name="pg3" type="text" class="style17" id="pg3" tabindex="18" size="8"></td> <td><input name="pg3" type="text" class="style17" id="pg3" tabindex="18" size="8"></td> <td><input name="cd3" type="text" class="style17" id="cd3" tabindex="19" size="9"></td> <td><input name="desc3" type="text" class="style17" id="desc32" tabindex="20" size="12"></td> <td><input name="price3" type="text" class="style17" id="price3" tabindex="21" size="6"></td> <td><input name="qty3" type="text" class="style17" id="qty3" tabindex="22" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>3</td> <td><input name="pg4" type="text" class="style17" id="pg4" tabindex="23" size="8"></td> <td><input name="pg4" type="text" class="style17" id="pg4" tabindex="23" size="8"></td> <td><input name="cd4" type="text" class="style17" id="cd4" tabindex="24" size="9"></td> <td><input name="desc4" type="text" class="style17" id="desc42" tabindex="25" size="12"></td> <td><input name="price4" type="text" class="style17" id="price4" tabindex="26" size="6"></td> <td><input name="qty4" type="text" class="style17" id="qty42" tabindex="27" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>4</td> <td><input name="pg5" type="text" class="style17" id="pg5" tabindex="28" size="8"></td> <td><input name="pg5" type="text" class="style17" id="pg5" tabindex="28" size="8"></td> <td><input name="cd5" type="text" class="style17" id="cd5" tabindex="29" size="9"></td> <td><input name="desc5" type="text" class="style17" id="desc5" tabindex="30" size="12"></td> <td><input name="price5" type="text" class="style17" id="price5" tabindex="31" size="6"></td> <td><input name="qty5" type="text" class="style17" id="qty5" tabindex="32" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>5</td> <td><input name="pg6" type="text" class="style17" id="pg6" tabindex="33" size="8"></td> <td><input name="pg6" type="text" class="style17" id="pg6" tabindex="33" size="8"></td> <td><input name="cd6" type="text" class="style17" id="cd6" tabindex="34" size="9"></td> <td><input name="desc6" type="text" class="style17" id="desc6" tabindex="35" size="12"></td> <td><input name="price6" type="text" class="style17" id="price6" tabindex="36" size="6"></td> <td><input name="qty6" type="text" class="style17" id="qty6" tabindex="37" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>6</td> <td><input name="pg7" type="text" class="style17" id="pg7" tabindex="38" size="8"></td> <td><input name="pg7" type="text" class="style17" id="pg7" tabindex="38" size="8"></td> <td><input name="cd7" type="text" class="style17" id="cd7" tabindex="39" size="9"></td> <td><input name="desc7" type="text" class="style17" id="desc7" tabindex="40" size="12"></td> <td><input name="price7" type="text" class="style17" id="price172" tabindex="41" size="6"></td> <td><input name="qty7" type="text" class="style17" id="qty7" tabindex="42" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>7</td> <td><input name="pg8" type="text" class="style17" id="pg8" tabindex="43" size="8"></td> <td><input name="pg8" type="text" class="style17" id="pg8" tabindex="43" size="8"></td> <td><input name="cd8" type="text" class="style17" id="cd8" tabindex="44" size="9"></td> <td><input name="desc8" type="text" class="style17" id="desc8" tabindex="45" size="12"></td> <td><input name="price8" type="text" class="style17" id="price8" tabindex="46" size="6"></td> <td><input name="qty8" type="text" class="style17" id="qty8" tabindex="47" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>8</td> <td><input name="pg9" type="text" class="style17" id="pg9" tabindex="48" size="8"></td> <td><input name="pg9" type="text" class="style17" id="pg9" tabindex="48" size="8"></td> <td><input name="cd9" type="text" class="style17" id="cd9" tabindex="49" size="9"></td> <td><input name="desc9" type="text" class="style17" id="desc9" tabindex="50" size="12"></td> <td><input name="price9" type="text" class="style17" id="price9" tabindex="51" size="6"></td> <td><input name="qty9" type="text" class="style17" id="qty9" tabindex="52" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>9</td> <td><input name="pga" type="text" class="style17" id="pga" tabindex="53" size="8"></td> <td><input name="pga" type="text" class="style17" id="pga" tabindex="53" size="8"></td> <td><input name="cda" type="text" class="style17" id="cda" tabindex="54" size="9"></td> <td><input name="desca" type="text" class="style17" id="desca" tabindex="55" size="12"></td> <td><input name="pricea" type="text" class="style17" id="pricea" tabindex="56" size="6"></td> <td><input name="qtya" type="text" class="style17" id="qtya" tabindex="57" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>10</td> <td><input name="pgb" type="text" class="style17" id="pgb" tabindex="58" size="8"></td> <td><input name="pgb" type="text" class="style17" id="pgb" tabindex="58" size="8"></td> <td><input name="cdb" type="text" class="style17" id="cdb" tabindex="59" size="9"></td> <td><input name="descb" type="text" class="style17" id="descb" tabindex="60" size="12"></td> <td><input name="priceb" type="text" class="style17" id="priceb" tabindex="61" size="6"></td> <td><input name="qtyb" type="text" class="style17" id="qtyb" tabindex="62" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td> </td> <td> </td> <td> </td> <td> </td> <td><div align="right">Total</div></td> <td><input name="pricec" type="text" class="style17" id="pricec" tabindex="66" size="6"></td> <td><input name="qtyc" type="text" class="style17" id="qtyc" tabindex="67" size="3"></td> </tr> <tr bgcolor="#3E55A7"> <td colspan="10" class="style9"> </td> </tr> <tr align="left" valign="top" bordercolor="#FFFFFF" bgcolor="#C7CFE9"> <td colspan="10" class="style10"><span class="style17">COMMENTS / DELIVERY INSTRUCTIONS: </span><br> <textarea name="comments" cols="30" rows="3" class="style17" id="comments"></textarea> <br></td> </tr> <tr bgcolor="#3E55A7"> <td colspan="10" class="style13"> </td> </tr> <tr bgcolor="#3E55A7"> <td colspan="10" class="style13"> </td> </tr> </table> <table width="80%" border="0"> <tr> <th scope="col"> </th> </tr> </table> <input type="SUBMIT" name="Submit" value="Submit Order"> Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/ Share on other sites More sharing options...
fortnox007 Posted October 19, 2010 Share Posted October 19, 2010 Well first of all, i would start of separating your CSS from you code. in-line style makes it hard (chaotic) to read besides that it is not a very nice practise. external stylesheets are much easier and faster to maintain. Than i would just make a simple version of a form that just sends a little info instead of a huge file with a greater chance of making mistakes. If you can do the simple 'small' one you can do the big one. That way it's easier to isolate the problem, and easier for us to solve. Third post your code in code tags, this isn't fun to read at all. Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124141 Share on other sites More sharing options...
Pikachu2000 Posted October 19, 2010 Share Posted October 19, 2010 You're going to need to fix the field naming problems first. You can't give two fields the same name as you've done with the first two fields in each group, unless you make them an array (which is probably not the best way to handle this). Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124142 Share on other sites More sharing options...
racercam Posted October 20, 2010 Author Share Posted October 20, 2010 Unfortunately i have very little knowledge of coding and the guides ive read might aswell be written in russian! I just use the design view and ' wizards ' to create the more complex stuff. so I have no idea about css or how to identify and sort the labels etc correctly. Would one of you be kind enough to fix the errors etc in return for some beer tokens? Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124277 Share on other sites More sharing options...
racercam Posted October 20, 2010 Author Share Posted October 20, 2010 im not sure if my php follow page is right either! Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124281 Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 im not sure if my php follow page is right either! Well the thing is you didn't post it, so it's a pretty visionary task to judge/solve that one. So if you post that script (in the code tags please) and say what you are expecting and what you have so far if there are any errors etc. so we have something to work with. Also i would recommend first start with the basics. Don't ask others to solve you're stuff and deliver a finished product, you don't learn anything from that. Read this easy to follow guide on forms: http://www.tizag.com/phpT/forms.php after that you should be able to make a very simple form just like I suggested. Not with all the fancy classes you have now. just something with a name field and a message field that you send to another page. Ones you know how to do that it's easy to fix the stuff you have yourself trust me. I could also to recommend to get Netbeans (php version). its a free editor that helps to write sound code. I have the impression your using some wicked editor now that doesn't contribute in your learning curve. Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124305 Share on other sites More sharing options...
racercam Posted October 20, 2010 Author Share Posted October 20, 2010 im not sure if my php follow page is right either! Well the thing is you didn't post it, so it's a pretty visionary task to judge/solve that one. So if you post that script (in the code tags please) and say what you are expecting and what you have so far if there are any errors etc. so we have something to work with. Also i would recommend first start with the basics. Don't ask others to solve you're stuff and deliver a finished product, you don't learn anything from that. Read this easy to follow guide on forms: http://www.tizag.com/phpT/forms.php after that you should be able to make a very simple form just like I suggested. Not with all the fancy classes you have now. just something with a name field and a message field that you send to another page. Ones you know how to do that it's easy to fix the stuff you have yourself trust me. I could also to recommend to get Netbeans (php version). its a free editor that helps to write sound code. I have the impression your using some wicked editor now that doesn't contribute in your learning curve. Ok thanks for that... very usefull info in idiots guide speak. I understand that , so i'll have a play this evening. Many Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124310 Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 make sure to get Netbeans, while typing it gives hints and it's way better than those so claimed customer friendly bulcrap editors. This way you understand how to reproduce stuff instead of relying on others. Love to see your example and will help you get the basics understood. good luck! Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124329 Share on other sites More sharing options...
racercam Posted October 20, 2010 Author Share Posted October 20, 2010 had a quick test part way through tp check errors etc and realised my php code doesnt have the bit where it e-mails me whats the code for that? Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124572 Share on other sites More sharing options...
Pikachu2000 Posted October 20, 2010 Share Posted October 20, 2010 mail() Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124574 Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 had a quick test part way through tp check errors etc and realised my php code doesnt have the bit where it e-mails me whats the code for that? mail() Also here i would just test out the mail function itself, ones your familiar with it, integrate it in your form. that way it's easier to isolate any problems if they may occur. Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124589 Share on other sites More sharing options...
racercam Posted October 20, 2010 Author Share Posted October 20, 2010 like this?: <html> <body> <?php mail("[email protected]") "Thank you for ordering from US ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124593 Share on other sites More sharing options...
phpfreak Posted October 20, 2010 Share Posted October 20, 2010 like this?: <html> <body> <?php mail("[email protected]") "Thank you for ordering from US ?> </body> </html> That wouldn't do much if anything at all. The Mail function handles a few arguments: mail ($to, $subject, $message) Please read up on the function in more detail: http://www.php.net/manual/en/function.mail.php Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124601 Share on other sites More sharing options...
racercam Posted October 21, 2010 Author Share Posted October 21, 2010 this the right idea? <?php // The message $message = " Full Name: " . $_POST['field_1'] . " Address: " . $_POST['field_2'] . " Post Code: " . $_POST['field_3'] . " E-Mail Address: " . $_POST['field_4'] . " Page Number: " . $_POST['field_5'] . " Product Code: " . $_POST['field_6'] . " Product Description: " . $_POST['field_7'] . " Phone Number: " . $_POST['field_8'] . " Price (£): " . $_POST['field_9'] . " Special Delivery Instructions: " . $_POST['field_10'] . // Send mail('[email protected]', 'Online Order', $message); ?> Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124906 Share on other sites More sharing options...
racercam Posted October 21, 2010 Author Share Posted October 21, 2010 this sends the email but doesnt capture the data... what could be the reason for that? All i get is a blank email with the correct subject line Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124945 Share on other sites More sharing options...
Pikachu2000 Posted October 21, 2010 Share Posted October 21, 2010 If that's the actual code, you never close the parentheses and terminate the statement where you assign $message = Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124950 Share on other sites More sharing options...
racercam Posted October 21, 2010 Author Share Posted October 21, 2010 how do you do that then? also what code do i need to put in to load a 'thankyou page' i've got the page in html Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1124959 Share on other sites More sharing options...
Pikachu2000 Posted October 21, 2010 Share Posted October 21, 2010 If it were me, I'd set it up like this <?php // The message $message = "Full Name: {$_POST['field_1']}\n Address: {$_POST['field_2']}\n Post Code: {$_POST['field_3']}\n E-Mail Address: {$_POST['field_4']}\n Page Number: {$_POST['field_5']}\n Product Code: {$_POST['field_6']}\n Product Description: {$_POST['field_7']}\n Phone Number: {$_POST['field_8']}\n Price (£): {$_POST['field_9']}\n Special Delivery Instructions: {$_POST['field_10']}"; // Send $success = "path/to/your/success_script.php"; if( mail('[email protected]', 'Online Order', $message) ) { header('Location: ' . $success); exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1125003 Share on other sites More sharing options...
racercam Posted October 22, 2010 Author Share Posted October 22, 2010 thanks much.... that seems to be working ok! Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1125139 Share on other sites More sharing options...
racercam Posted October 25, 2010 Author Share Posted October 25, 2010 My code is below but it wont process, the submit button goes to 'process.php' and not through to confirm.html and send email? -------------------------------------------------------------------------------------- <?php // The message $message = "Full Name: {$_POST['NAME']}\n Address: {$_POST['ADDRESS']}\n Town: {$_POST['TOWN']}\n Post Code: {$_POST['POSTCODE']}\n Phone Number: {$_POST['PHONE']}\n Email: {$_POST['email']}\n $Line 1; Page Number: {$_POST['PageNumber']}\n Product Code: {$_POST['ProductCode']}\n Product Description: {$_POST['Description']}\n Price (£): {$_POST['Price']}\n Quantity: {$_POST['Quantity']}"; Total: {$_POST['Total']}"; $Line 2; Page Number: {$_POST['PageNumber2']}\n Product Code: {$_POST['ProductCode2']}\n Product Description: {$_POST['Description2']}\n Price (£): {$_POST['Price2']}\n Quantity: {$_POST['Quantity2']}"; Total: {$_POST['Total2']}"; $Line 3; Page Number: {$_POST['PageNumber3']}\n Product Code: {$_POST['ProductCode3']}\n Product Description: {$_POST['Description3']}\n Price (£): {$_POST['Price3']}\n Quantity: {$_POST['Quantity3']}"; Total: {$_POST['Total3']}"; $Line 4; Page Number: {$_POST['PageNumber4']}\n Product Code: {$_POST['ProductCode4']}\n Product Description: {$_POST['Description4']}\n Price (£): {$_POST['Price4']}\n Quantity: {$_POST['Quantity4']}"; Total: {$_POST['Total4']}"; $Line 5; Page Number: {$_POST['PageNumber5']}\n Product Code: {$_POST['ProductCode5']}\n Product Description: {$_POST['Description5']}\n Price (£): {$_POST['Price5']}\n Quantity: {$_POST['Quantity5']}"; Total: {$_POST['Total5']}"; $Line 6; Page Number: {$_POST['PageNumber6']}\n Product Code: {$_POST['ProductCode6']}\n Product Description: {$_POST['Description6']}\n Price (£): {$_POST['Price6']}\n Quantity: {$_POST['Quantity6']}"; Total: {$_POST['Total6']}"; $Line 7; Page Number: {$_POST['PageNumber7']}\n Product Code: {$_POST['ProductCode7']}\n Product Description: {$_POST['Description7']}\n Price (£): {$_POST['Price7']}\n Quantity: {$_POST['Quantity7']}"; Total: {$_POST['Total7']}"; $Line 8; Page Number: {$_POST['PageNumber8']}\n Product Code: {$_POST['ProductCode8']}\n Product Description: {$_POST['Description8']}\n Price (£): {$_POST['Price8']}\n Quantity: {$_POST['Quantity8']}"; Total: {$_POST['Total8']}"; $Line 9; Page Number: {$_POST['PageNumber9']}\n Product Code: {$_POST['ProductCode9']}\n Product Description: {$_POST['Description9']}\n Price (£): {$_POST['Price9']}\n Quantity: {$_POST['Quantity9']}"; Total: {$_POST['Total9']}"; $Line 10; Page Number: {$_POST['PageNumber10']}\n Product Code: {$_POST['ProductCode10']}\n Product Description: {$_POST['Description10']}\n Price (£): {$_POST['Price10']}\n Quantity: {$_POST['Quantity10']}"; Total: {$_POST['Total10']}"; Grand Total: {$_POST['GrandTotal']}"; // Send $success = "/confirm.html"; if( mail('[email protected]', 'Online Order', $message) ) { header('Location: ' . $success); exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/216303-newbie-trying-to-get-my-head-around-web-forms/#findComment-1126342 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.