select /store selection to $_SESSION['id'] / redirect fails

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); ?>

the id field has the value I need in $_SESSION[‘id’] which is gained via the -> $query = “SELECT * FROM customer”; (it is an auto increment distinct value). I need this value carried over to add-job.php from index.php via the $_SESSION[‘id’] variable. This is a dynamic value returned from the database query.

mysql> SELECT * FROM customer
-> ;
±—±----------±-----------±-----------±-----------+
| id | cust_name | cust_addr | cust_phone | cust_email |
±—±----------±-----------±-----------±-----------+
| 1 | bob | 666 bo rd | 2124442222 | [email protected] |
| 2 | dude | 666 jo rd | 2124445555 | bub |
| 3 | nnn | kju | 6666 | [email protected] |
| 4 | brad | 888 | 2124444444 | [email protected] |
| 5 | brad2 | smirk | 2147483647 | [email protected] |
| 6 | another | 8888 bh rd | 2147483647 | knarly@me |
| 7 | peach | 69 too | 2147483647 | iuhdihih |
| 8 | peachy | 4442222 rd | 0 | [email protected] |
±—±----------±-----------±-----------±-----------+
8 rows in set (0.00 sec)

mysql> desc customer;
±-----------±-------------±-----±----±--------±---------------+
| Field | Type | Null | Key | Default | Extra |
±-----------±-------------±-----±----±--------±---------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| cust_name | varchar(100) | NO | | NULL | |
| cust_addr | varchar(180) | NO | | NULL | |
| cust_phone | int(11) | YES | | NULL | |
| cust_email | varchar(90) | YES | | NULL | |
±-----------±-------------±-----±----±--------±---------------+
5 rows in set (0.07 sec)

Here is a visual

I need this http://i.imgur.com/ZZl5IKd.png

to go here http://i.imgur.com/xyRmKGb.png

and be reflected here via $_SESSION[‘id’] http://i.imgur.com/Ui0m2QT.png

I’m not shy about a bitcoin payout brother. I have one coming up for .0104~ and it’s all yours. A little under your requested but I’m not rich. But always willing to offer/give.
Thank you for your time. Can you send me a bitcoin address?

Working on your solution now my friend.

create table customer (
id int NOT NULL auto_increment,
cust_name varchar(100) NOT NULL,
cust_addr varchar(180) NOT NULL,
cust_phone int(11),
cust_email varchar(90),
PRIMARY KEY (id)
);

Download the attached file.

I am in the process of setting up Bitcoin by the way.


tunage.zip (1.03 KB)

almost there but even the file you sent me doesn’t appear to redirect or carry the SESSION variable.

working on it now.

The download works perfectly. There is nothing for you to do to make it work. After you change the database setting, all you have to do is select something from the dropdown and hit the submit button. It then goes to the next page and displays the session that was set.

It redirects when I enable the if($_POST){ in the header. but no session variable yet.
Looking into that now.

What do you mean if you enable it? There is absolutely nothing for you to change except the database connection. There is NOTHING to look into. If you change anything else you will break it.

This code http://i.imgur.com/PtRR4uu.png that was in the .zip file, does not rediect or carry the session variable.

When I implement ;
if($_POST){

    //store as session variable
    $_SESSION['id'] = $_POST['id'];
    //forward browser
    die(header("Location: add-job.php"));

}

The redirect returns, but I get a NULL value for the $_SESSION[‘id’]

That is not the code from the zip file tunage.zip. Delete everything you have and re download the ZIP file a few posts up.

Thank you!!!

Your welcome. Thanks for mentioning bitcoin. I have never looked into before. I am now seeing I can develop apps with it. Just might head me in a new direction.

Sponsor our Newsletter | Privacy Policy | Terms of Service