heggjen Posted October 18, 2012 Share Posted October 18, 2012 I need some help with an order form I´m trying to get to work. My first problem is to send a mail without the posts that are empty. Then I want to send the mail in html and make it look a little bit as a order form, and not just plain text. I understand just a little bit of php, and not nearly enough to get the result I want... Hope someone can help... (The content text in the form is in Norwegian, so if you don´t understand it, its understanding..... ) orderform.php Quote Link to comment https://forums.phpfreaks.com/topic/269614-need-help-with-mail-form/ Share on other sites More sharing options...
JohnTipperton Posted October 18, 2012 Share Posted October 18, 2012 (edited) what exactly result do you want to appear? is it a mail form with javascript validation and a css mail form result? http://css-tricks.com/sending-nice-html-email-with-php/ try this link this email form contains CSS. Edited October 18, 2012 by JohnTipperton Quote Link to comment https://forums.phpfreaks.com/topic/269614-need-help-with-mail-form/#findComment-1385944 Share on other sites More sharing options...
heggjen Posted October 19, 2012 Author Share Posted October 19, 2012 (edited) I would like to get a mail that don´t show the post that are empty, and where the result have a layout that makes it a litte bit more understanding than with just plain text. The result now is like: Product: Number: Product: Number: Product: Number: I would like to get it more like this, with to extra colums that can be filled in manually after ther order is printed and executed (all within a grid of some sort) : Product: Number: Price: Sum: xxxxx xx xxxxx xx xxxxx xx xxxxx xx xxxxx xx xxxxx xx Total cost: I have looked at the code from css-tricks, put do not see just yet how I would get it to work toghether with te code I have now. It`s probably real easy to do, but I can´t quite see it now... Edited October 19, 2012 by heggjen Quote Link to comment https://forums.phpfreaks.com/topic/269614-need-help-with-mail-form/#findComment-1386245 Share on other sites More sharing options...
JohnTipperton Posted October 19, 2012 Share Posted October 19, 2012 can you show me the code? Quote Link to comment https://forums.phpfreaks.com/topic/269614-need-help-with-mail-form/#findComment-1386247 Share on other sites More sharing options...
heggjen Posted October 19, 2012 Author Share Posted October 19, 2012 It`s attached to my initial post....or do you mean some other code? Quote Link to comment https://forums.phpfreaks.com/topic/269614-need-help-with-mail-form/#findComment-1386248 Share on other sites More sharing options...
JohnTipperton Posted October 19, 2012 Share Posted October 19, 2012 just create a table to make it presentable <table width="425" border="1"> <tr> <td width="107">Product</td> <td width="98">Number</td> <td width="92">Price</td> <td width="100">Sum</td> </tr> <tr> <td height="42">xxxxxx</td> <td>xxxxxxx</td> <td>xxx</td> <td>xxx</td> </tr> <tr> <td height="44">xxxxxx</td> <td>xxxxxxx</td> <td>xxx</td> <td>xx</td> </tr> <tr> <td height="49">xxxxxx</td> <td>xxxxxxx</td> <td>xx</td> <td>xx</td> </tr> <tr> <td height="50">xxxxxx</td> <td>xxxxxxx</td> <td>xx</td> <td>xx</td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/269614-need-help-with-mail-form/#findComment-1386249 Share on other sites More sharing options...
heggjen Posted October 19, 2012 Author Share Posted October 19, 2012 That is ok, put how do I get the result into the right place in the table, and just the results that have a value... My trouble is the connetction between the presentation of the form on the web and the presentation in the mail. It`s the php I need to get it done, that is the big problem... Quote Link to comment https://forums.phpfreaks.com/topic/269614-need-help-with-mail-form/#findComment-1386251 Share on other sites More sharing options...
JohnTipperton Posted October 19, 2012 Share Posted October 19, 2012 (edited) it should be like this if in php <table width="425" border="1"> <tr> <td width="107">Product</td> <td width="98">Number</td> <td width="92">Price</td> <td width="100">Sum</td> </tr> <?php while($row = mysql_fetch_array($result)) { ?> <tr> <td height="42"><?php $row['Product']; ?></td> <td><?php $row['Number']; ?></td> <td><?php $row['Price']; ?></td> <td><?php $row['Sum']; ?></td> </tr> <?php } ?> </table> Edited October 19, 2012 by JohnTipperton Quote Link to comment https://forums.phpfreaks.com/topic/269614-need-help-with-mail-form/#findComment-1386254 Share on other sites More sharing options...
heggjen Posted October 19, 2012 Author Share Posted October 19, 2012 I may be stupid, but if you see my code, how would I use youre suggestion to get the mail to present the result like I want to? As I said, is it the connection between the collection of the information and the sending of the results I then get, in the way that I want, that is the problem. Sorry if I am repeating myself... ...and my lack of understanding... Quote Link to comment https://forums.phpfreaks.com/topic/269614-need-help-with-mail-form/#findComment-1386258 Share on other sites More sharing options...
heggjen Posted October 19, 2012 Author Share Posted October 19, 2012 The trouble is what to do here: $whole_message = '<html><body>'; $whole_message = '<table border="0" cellpadding="1" cellspacing="0" width="450"> <tr> <td colspan="2"><b>Elektronisk bestilling er registrert:</b><br><br></td> </tr>'; foreach ($_POST as $key => $val) { if ($key=="Submit_x" or ($key=="Submit_y" or ($key=="sendmail" or ($key=="recipient" or ($key=="subject"))))) { } else { if (is_array($_POST[$key])){ $whole_message .= '<tr> <td width="150" valign="top"><b>'.$key .':</b></td> <td valign="top">'. getArrayVals($_POST[$key]) .'</td> </tr>'; }else{ $whole_message .= '<tr> <td width="150" valign="top"><b>'.$key .':</b></td> <td valign="top">'. $_POST[$key] .'</td> </tr>'; } } } $whole_message .= '</table></body></html>'; if (neted_mail ($recipient,$subject,$whole_message,$headers)) { echo ' <script type="text/javascript">window.alert("Bestillinga er oversendt til kantina, og du vil få ei bekrefting når bestillinga er godteken.")</script>'; } else { echo ' <script type="text/javascript">window.alert("Feil! Noko gjekk gale, bestillinga er ikkje motteken av oss. Prøv igjen.")</script>'; } break; default: displayEmailForm (); } function getArrayVals($arr){ $layout = ""; foreach ($arr as $key => $val) { $layout .= $key . ":" . $val . ":"; } return $layout; } Quote Link to comment https://forums.phpfreaks.com/topic/269614-need-help-with-mail-form/#findComment-1386272 Share on other sites More sharing options...
JohnTipperton Posted October 20, 2012 Share Posted October 20, 2012 (edited) The trouble is what to do here: $whole_message = '<html><body>'; $whole_message = '<table border="0" cellpadding="1" cellspacing="0" width="450"> <tr> <td colspan="2"><b>Elektronisk bestilling er registrert:</b><br><br></td> </tr>'; foreach ($_POST as $key => $val) { if ($key=="Submit_x" or ($key=="Submit_y" or ($key=="sendmail" or ($key=="recipient" or ($key=="subject"))))) { } else { if (is_array($_POST[$key])){ $whole_message .= '<tr> <td width="150" valign="top"><b>'.$key .':</b></td> <td valign="top">'. getArrayVals($_POST[$key]) .'</td> </tr>'; }else{ $whole_message .= '<tr> <td width="150" valign="top"><b>'.$key .':</b></td> <td valign="top">'. $_POST[$key] .'</td> </tr>'; } } } $whole_message .= '</table></body></html>'; if (neted_mail ($recipient,$subject,$whole_message,$headers)) { echo ' <script type="text/javascript">window.alert("Bestillinga er oversendt til kantina, og du vil få ei bekrefting når bestillinga er godteken.")</script>'; } else { echo ' <script type="text/javascript">window.alert("Feil! Noko gjekk gale, bestillinga er ikkje motteken av oss. Prøv igjen.")</script>'; } break; default: displayEmailForm (); } function getArrayVals($arr){ $layout = ""; foreach ($arr as $key => $val) { $layout .= $key . ":" . $val . ":"; } return $layout; } it would be more readable if you use {code][/code] tags Edited October 20, 2012 by JohnTipperton Quote Link to comment https://forums.phpfreaks.com/topic/269614-need-help-with-mail-form/#findComment-1386521 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.