Jump to content

Arrays and Sessions!


sodascape

Recommended Posts

The input tag from the form:
[code]
<input type="checkbox" name="store[]" value="blue" />
<input type="checkbox" name="store[]" value="red" />
<input type="checkbox" name="store[]" value="green" />
[/code]

Turning the array into a session
[code]
// TURNING THE ARRAY INTO A SESSION
$_SESSION['bag'] = $_POST['store'];
[/code]

PUTTING THIS INTO THE DATABASE WITH OTHER VARIABLES NOT IN THE ARRAY
[code]
// UPLOAD THIS SHTuff TO THE DATABASE STORE
mysql_connect('localhost','stickys_stsp','stsp');
mysql_select_db( 'stickys_vbase' );

// DUMP ARRAY OUT OF SESSION
foreach ($_SESSION['bag'] as $bag) {

echo '<td align="center"><img src="setcaps/'.$bag.'" border="1" alt="" /></td>';

$storebag = "INSERT INTO store (id, username, setcap, today, expires, key) VALUES (0, $user, $bag, 0, 0, $key)";
// Display Results
$bagr = mysql_query ($storebag);

} // end foreach
[/code]
Link to comment
https://forums.phpfreaks.com/topic/27411-arrays-and-sessions/#findComment-125382
Share on other sites

[code]Array ( [0] => red.jpg [1] => green.jpg [2] => blue.jpg )[/code]
THAT'S WHAT I GET WHEN I PRINT_R THE ARRAY

[code]Array ( [0] => red.jpg [1] => green.jpg [2] => blue.jpg )[/code]
THAT'S THE RESPONSE I GET WHEN I PRINT_R THE SESSION.

EVERYTHING SEEMS TO BE passing fine.
Link to comment
https://forums.phpfreaks.com/topic/27411-arrays-and-sessions/#findComment-125438
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.