Jump to content

Recommended Posts

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... :confused:

 

Hope someone can help...

 

(The content text in the form is in Norwegian, so if you don´t understand it, its understanding..... ::) )

 

 

orderform.php

Link to comment
https://forums.phpfreaks.com/topic/269614-need-help-with-mail-form/
Share on other sites

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 by JohnTipperton

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 by heggjen

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>

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... ::)

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 by JohnTipperton

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... :happy-04:

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;

}

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 by JohnTipperton
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.