Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8398599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:05:30+00:00 2026-06-09T21:05:30+00:00

I have an order form (table) that I need to be sent to an

  • 0

I have an order form (table) that I need to be sent to an email address.
I understand the basics of how to send an email in PHP, but not the specifics
of this situation (taking the information of the cookie array + form elements and put them in body of the PHP mailer)

I am using this link’s answer to store the order form as an array in a cookie

Then I use this javascript to create the table in HTML, inside the #catalog div. The important part is the for loop that makes the table. Using list.items(); one can list the “cookie array” as an array

function loopArrayMail() { 
if ($.cookie('productWishlist') == null) {
    html = ""; $('#catalog').html(html);
} else {
    var cookie = $.cookie("productWishlist"); var items = cookie ? cookie.split(/,/) : new Array();
    var html = "<table><tr><th>Product</th><th># to order</th></tr>";
    for(var i=0;i<items.length;i++){ html += "<tr><td width='450'>"+items[i]+"</td><td><input type='text' name='numberOfItems' /></td></tr>"; }
    html += "</table>"; $('#catalog').html(html);
}}

There is a text input next to each item in the order form for the user to input the # of items they want.
How would I send the contents of the table and each form input as an email in PHP?

My guess is that I’d have to take the cookie array, and with each iteration have an array of all the text inputs and use foreach so that they are together in the email (unsure of how to do this exactly). It is also important that there can be any number of text inputs as the number of items on the order form will increase/decrease.

Here is an example of using foreach to get multiple input boxes, but how might I combine the array from my cookie with the text inputs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:05:32+00:00Added an answer on June 9, 2026 at 9:05 pm

    First you must give the form elements a name followed by [] indicating that it is an array, when you create the form elements in the loopArrayMail() function.

    for(var i=0;i<items.length;i++){
      html += "<tr><td width='450'>"+items[i]+"</td><td><input type='text' name='ordernum[]' size='8' /></td></tr>";
    }
    

    Since the cookie is a string you must first explode the string based on the delimiter which is a comma. Place the two arrays into variables. Then use a for loop to go through all of the array.

    function explode_trim($str, $delimiter = ',') {
      if ( is_string($delimiter) ) {
        $str = trim(preg_replace('|\\s*(?:' . preg_quote($delimiter) . ')\\s*|', $delimiter, $str));
        return explode($delimiter, $str);
      } 
    return $str; }
    
    $orderCookie = explode_trim($_COOKIE['productWishlist']);
    $orderNum = $_POST['ordernum'];
    
    for ( $i = 0; $i < count($orderCookie); $i++) {
      echo $orderCookie[$i] . ' = ' . $orderNum[$i] . '<br />';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an order form with about 30 text fields that contain numerical values.
I have inherited a project, that provides an order form to a customer. The
I have a table that has the user ID already in it, but some
I have a form with sequentially named fields (field1, field2, etc) that I need
I have a homework assignment that asks to create an order form. The order
I have set up a rails application that uses single table inheritance but I
I have a multi-step order form built in this manner: Step 1: Choose category
I have a registration form and used fieldset to order the input fields in
I have order confirmation html emails being parsed by a PHP script. The script
I have a form that once submitted some of its result are stored in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.