Jump to content

Recommended Posts

Hello,

 

I am trying to pass multiple values, via an implode function. However, it isnt working. Here is the code from the first page, then the second page.

 

<?php

if(isset($_POST['numItems'])) {

$checkboxes = $_POST['numItems'];

$string = implode($value,"^");

echo $string;

}

?>

 

<form name='CartItem' action='https://www.ram-mount.com/RamCart/CartPutItem.php' method='POST'>

<input type='checkbox' name='numItems[]' value='RAM-VB-162'>

<input type='checkbox' name='numItems[]' value='RAM-VB-154'>

<input type='submit' value='Add To Cart'>

</form>

 

Second Page:

 

<?php

include_once('./CartDBCxn.php');

if (!isset($_COOKIE['sess'])) {

session_start();

$usrSession = session_id();

setcookie('sess',$usrSession,0,'/','ram-mount.com');

} else {

$usrSession = $_COOKIE['sess'];

}

if (isset($_GET['act'])) {

if ($_GET['act'] == 'remove') {

removeCartItem($_GET['part'],$usrSession);

}

}

if (isset($_POST['numItems'])) {

// Process the update code

$numItems = $_POST['numItems'];

$items = $_POST;

echo ("\n\n\n <!-- ");

print_r($_POST);

echo (" --> \n\n\n");

for ($x=0;$x < $numItems; $x++) {

$itm = 'item'.($x+1);

$quan = 'Qty'.($x+1);

changeCartItem($items[$itm],$usrSession,$items[$quan]);

}

}

?>

Link to comment
https://forums.phpfreaks.com/topic/123969-implode-function-not-working/
Share on other sites

Unfortunately that didn't work.  Any other suggestions?  Thanks.

 

<?php

if(isset($_POST['numItems'])) {

$checkboxes = $_POST['numItems'];

$string = implode("^",$value);

echo $string;

}

?>

 

<form name='CartItem' action='https://www.ram-mount.com/RamCart/CartPutItem.php' method='POST'>

<input type='checkbox' name='numItems[]' value='RAM-VB-162'>

<input type='checkbox' name='numItems[]' value='RAM-VB-154'>

<input type='submit' value='Add To Cart'>

</form>

If I do the following then the cart updates; however I want to provide the user a choice based on check boxes.

 

<form name='CartItem' action='https://www.ram-mount.com/RamCart/CartPutItem.php' method='POST'>

<input type='hidden' name='part' value='RAM-VB-154^RAM-VB-162'><input type='submit' value='Add To Cart'>

</form>

Unfortunately that didn't work. Any other suggestions? Thanks.

 

<?php

if(isset($_POST['numItems'])) {

$checkboxes = $_POST['numItems'];

$string = implode("^",$value);

echo $string;

}

?>

 

<form name='CartItem' action='https://www.ram-mount.com/RamCart/CartPutItem.php' method='POST'>

<input type='checkbox' name='numItems[]' value='RAM-VB-162'>

<input type='checkbox' name='numItems[]' value='RAM-VB-154'>

<input type='submit' value='Add To Cart'>

</form>

$value should be $checkboxes.

Almost worked!  One of the two values passed through, the RAM-VB-154

 

Here is the page online:

http://www.ram-mount.com/wizards/test.php

 

Any suggestions on how to push both values through?  Thanks

 

 

<?php

if(isset($_POST['part'])) {

$checkboxes = $_POST['part'];

$string = implode("^",$checkboxes);

echo $string;

}

?>

 

<form name='CartItem' action='https://www.ram-mount.com/RamCart/CartPutItem.php' method='POST'>

<input type='checkbox' name='part' value='RAM-VB-162'>

<input type='checkbox' name='part' value='RAM-VB-154'>

<input type='submit' value='Add To Cart'>

</form>

 

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.