Jump to content

vassili

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

vassili's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i have this array $cartSizes[$productid] where $productid is an array of 8 values (1-. $cartSizes is stored in a $_SESSION array like this $_SESSION['cartSizes'] = $cartSizes; an example of a $_SESSION['cartSizes'] array that has 2 $productid would be: [cartSizes] => Array ( [8061ABL] => Array ( [1] => 0 [2] => 3 [3] => 4 [4] => 5 [5] => 0 [6] => 0 [7] => 0 [8] => 0 )[6105AAOAU] => Array ( [1] => 3 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 ) ) i want to get the sum of $_SESSION['cartSizes']. but this doesn't work...i keep getting "0". sum_array($_SESSION['cartSizes']) what's wrong?
  2. yeah, after trial and error, this works too. value=" '.$_SESSION['cartSizes'][$id][1].' "
  3. in show.php i have this... $cartSizes = isset($_SESSION['cartSizes']) ? $_SESSION['cartSizes'] : array(); $maxSizes = 8; $productid = $_GET['id']; $cartSizes[$productid] = array(); for( $i=1;$i<$maxSizes; $i++ ){ $cartSizes[$productid][$i] += $_POST['qty'.$i]; } $_SESSION['cartSizes'] = $cartSizes; so now array $cartSizes should be saved in session. now i want to place the value of $cartSizes[$productid][$i] into an input text field in another file called function.php. we'll say $i=1 so i want the value in $cartSizes[$productid][1] i need to place the value in this line of function.php $output[] = '<input type="hidden" name="qty'.$id.'" value="[b]I HAVE NO IDEA[/b]" size="3" maxlength="3" />'; thanks.
  4. i've looked everywhere online, and every guide seems to tell you how to set it up but not really tell you how the execution is nailed down. so i have a whole bunch of variables from a form via post. one variable, $order is a large querystring of HTML. it looks like this. <table align=\"center\" cellpadding=\"0\" border=\"0\"><tr><td><form action=\"cart.php?action=update\" method=\"post\" id=\"cart\"><table align=\"center\" cellpadding=\"10\" width=\"820\" border=\"0\"><tr><td style=\"border:1px solid #999;\"><a href=\"cart.php?action=delete&id=CSFT03CHI\" class=\"r\">Remove</a></td><td width=\"400\" style=\"border:1px solid #999;\">Men\'s 1/4 Zip Half Sleeve Pullover (albatross) in CHARCOAL/IVORY</td><td style=\"border:1px solid #999;\">$18.00</td><td width=\"50\" style=\"border:1px solid #999;\"><input type=\"text\" name=\"qtyCSFT03CHI\" value=\"11\" size=\"3\" maxlength=\"3\" /></td><td style=\"border:1px solid #999;\">$198.00</td></tr></table><p align=\"right\">Subtotal: <strong>$198.00</strong></p><div align=\"right\"><button type=\"submit\" id=\"mysubmit\">Update cart</button></div><p align=\"right\"><a href=\"memberindex.php\" >Back to Shopping...</a></p> </form></td></tr></table> the rest are simple strings to ID the sender. my submit code looks like this. <?php if(isset($_POST['submit'])) { $to = "xxx@gmail.com"; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['Comment']; $order = $_POST['order']; $subject = "New Order From $name_field"; $headers = "From: $name_field <order@xxx> \r\n"; $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message \n $order"; echo "Data has been submitted to $to!"; mail($to, $subject, $body, $headers); } else { echo "error: mail not delivered"; } ?> how do i format this so everything in $body shows up as html correctly in the email? now i know $order doesn't pass the validation right now, but all that needs to work is for me to see the the order...i wasn't thinking ahead when i added the function that spits out the $order querystring and now it's too late to change it.
  5. can anyone point me in the right direction on how to email the results of ShowCart(); ??? i really need help on this. i'd really appreciate it.
  6. hi all, im running into a roadblock that i can't seem to get past. my problem is 2 fold. i have this function showItems(). it basically spits out an array of the results of what users have added to their shopping cart. function showItems() { global $db; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<table align="center" cellpadding="0" border="0">'; $output[] = '<tr><td>'; $output[] = '<form action="cart.php?action=update" method="post" id="cart">'; $output[] = '<table align="center" cellpadding="10" width="820" border="0">'; foreach ($contents as $id=>$qty) { $sql = "SELECT * FROM item WHERE uniq_ID='$id'"; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr>'; $output[] = '<td style="border:1px solid #999;"><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>'; $output[] = '<td width="400" style="border:1px solid #999;">'.$name.' in '.$color.'</td>'; $output[] = '<td style="border:1px solid #999;">$'.$price.'</td>'; $output[] = '<td width="50" style="border:1px solid #999;"><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>'; $output[] = '<td style="border:1px solid #999;">$' . number_format($price * $qty, 2) . '</td>'; $total += $price * $qty; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<p align="right">Subtotal: <strong>$'. number_format($total,2).'</strong></p>'; $output[] = '<div align="right"><button type="submit" id="mysubmit">Update cart</button></div>'; $output[] = '<p align="right"><a href="memberindex.php" >Back to Shopping...</a></p> '; $output[] = '</form>'; } else { $output[] = '<p>Your cart is empty.</p>'; } $output[] = '</td></tr>'; $output[] = '</table>'; return join('',$output); } on another page (cart.php), i echo this function to display the results in cart.php. i also have a form on that page that requires the user to input personal info and then when he/she hits submit, i want everything (results of showItems() + information from the form) passed to submit.php where the code will group them together and send me an email. submit.php right now has test code that can send the information from the form to me. if(isset($_POST['submit'])) { $to = "me@gmail.com"; $subject = "order"; $name_field = $_POST['Name']; $email_field = $_POST['Email']; $message = $_POST['City']; $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message"; echo "Data has been submitted to $to!"; mail($to, $subject, $body); } else { echo "failed"; } i just don't know how to work int he showItems() results. also, sending the email is ok when i run from the actual host server online, but when i try to run it on a localhost through wampserver running windows XP, i get this error. Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing my php.ini looks like this [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. sendmail_from = me@localhost.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ;sendmail_path = ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ;mail.force_extra_parameters = phew...that was a mouthful, hopefully someone here understand what i need. thanks in advance.
×
×
  • 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.