Jump to content

mailing form results


sottise

Recommended Posts

I'm trying to finish off a basic order form for a client site to use, using PHP to process. I am essentially completing someone else's project, so I'm in a leeeetle bit over my head. I can print the results easily enough to the confirmation page, and I have the basics of the email down - it actually sends, returns contact name / address / total cost correctly and so on.

My problem comes from the one bit of code that actually requires a brain cell - returning the number of actual items ordered. On the order form, the user enters the desired quantity of each item, and the form calculates the cost. The item (item_BLEH) and the quantity (num_BLEH) need to be returned to the confirmation page and sent off in an email.

Currently this is all generated as below, which works fine for the confirmation page, but I'm having a minor brain malfunction and can't figure out how to get the list into an email.

How it looks:

[code]

function OrderedItems()
{
$complete = GetEntryPairs();
foreach ( $complete as $name=>$value )
{
    print "{$name} == {$value} <BR>\n";
}
}


function GetEntryPairs()
{
    global $_POST;    
    $complete_entries = array();        
    foreach ( $_POST as $name=>$value )
    {    
                 if ( Preg_Match("/^num_/i", $name) )
             {
                   continue;
               }
             else if ( Preg_Match("/^item_/i", $name) )
             {    
                    $t_name = Preg_Replace("/^item_/i", "", $name);
                    $amt = IntVal($_POST["num_{$t_name}"]);
                    if ( $amt > 0 )
                    {
                         $complete_entries[$t_name] = $amt;
                     }
             }
    }
    
    return $complete_entries;
}

[/code]

OrderedItems(); generates a list along the lines of Muffins == 5 SausageRolls == 8 which is all I really need at the moment. As I said, it works fine on the confirmation page, but I need to get that data into an email somehow, and I'm kinda stuck.

This is a very very very simple form, with no database connectivity. I'll be pushing to implement a decent system (damn bureaucracy) so I won't have to touch this stuff again, but for now I really need to get this working. Any help would be much appreciated.
Link to comment
Share on other sites

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.