I am trying to do a select / save selection to $_SESSION[‘id’] / redirect but the only value I am able to pass to $_SESSION[‘id’] is the target url and not the selection. output -> http://i.imgur.com/QeGb89X.png . instead of the var_dump() output saying ‘add-job.php’, it should report 3, 4, 5 or what ever the id is for the selection.
http://bpaste.net/show/NzwgIqHVghYzo5NIiqY4/
<?php require_once("header.php");?> <form name="addjob" method="POST" action="" onsubmit="return getURL(add-job.php)">
<select name="bolredir">
<?php
// selection box submit
$query = "SELECT * FROM customer";
$result = $odb->query($query);
$custkey;
// var_dump($result);
if($result->rowCount() > 0) {
foreach($result as $item) {
echo ‘<option value=’.$item[‘id’].’>’;
echo ($item[‘cust_name’] .",". $item[‘cust_addr’] .",". $item[‘cust_phone’] .",". $item[‘id’]."
\n");
echo ‘’;
$_SESSION[‘id’] = $item[‘id’];
}
}
// var_dump($_SESSION[‘cust_name’]);
?>
***************************************** header.php ***********************************
darknet064tokyo contactdb # cat header.php
<?php session_start(); if(isset($_POST['id'])){ //store as session variable $_SESSION['id'] = $_POST['id']; //forward browser header("Location: ".$_SESSION['id']); exit; } $host = "localhost"; $user = "custdb"; $pass = ""; $db = "accounting"; $odb = new PDO("mysql:host=" . $host . ";dbname=" . $db, $user, $pass); ?>