Solved

forms setting session on completion of a page

Posted on 2004-10-12
10
368 Views
Last Modified: 2013-12-12
Hi,

Please can someone point me in the correct direction. I am building a from from data coming in from any oracle db, from there, a table is build, and I am storing the information on a form. This is fine, and I can move across the four pages, of user input needed for the select statement, on the client site, the variables are being set correctly, and when I use the "get" method of moving between pages, I can see the correct HTTP_VARs being set. But, When I try to add all the information together, so the select can run, the last page can not read the HTTP_VAR information, even though I can read it from ther URL line. I have tired to place the infomation I need into a session file, but as that is set up before the user select the field, it does not contain any useful information. I have attached the code i am using below to build the table.
I am going arround in smaller and smaller circles here. I am using PHP 5 with register_globals off, as per the php suggestion.
Thanks in advance
Tim
+++++++++++++++++++++++++++++
<?php

session_start();
header("Cache-control: private");
# ie 6 fix needed when useing session stuff
require_once ('Connections/oracle.inc') ;
$statement = OCIparse ($c, "select column_name from user_tab_columns where table_name = 'TBG_T_NAMES' ");
$col_name = array() ;
OCIexecute($statement, OCI_DEFAULT) ;
 while (OCIFetch($statement)) {
           $t=ociresult($statement, COLUMN_NAME);
            array_push($col_name, $t) ;
      }            
?>

<body>

<form action="select2.php" method="post">
<table border="3">
<tr> <td></td><td>Yes</td><td>No</td><TD>who </TD></tr>
<tr>
<?php
$p="p-";

$i=400 ;
 foreach ( $col_name as $val) {
 $sess_val=$p.$i  ;
 session_register($name) ;
 ?>
 <td><?php echo$val;?> </td> <?php $HTTP_SESSION_VARS['$sess_val']=$i; ?>
<TD><label><input name="<?php echo $HTTP_SESSION_VARS['$sess_val']; ?>" type=radio value="y" > </label></td>
<TD><label><input name="<?php echo $HTTP_SESSION_VARS['$sess_val']; ?>" type=radio value="n" > </label></td>
<TD><label><input name="<?php echo $HTTP_SESSION_VARS['$sess_val']; ?>" type=radio value="w" checked > </label></td>

</tr>

<?php $i++ ;

       }

;       

unset ($i);

       ?>
       </table>
       <table border="4">
       <td><label><input name=number_of_sele type=text  value="" size="10">
       </label></td>
 </table>
<hr>
<hr>       
<input type="submit" value="Get List">
</form>
</body>

      





0
Comment
Question by:radical_mit
  • 4
  • 4
  • 2
10 Comments
 
LVL 12

Expert Comment

by:minichicken
ID: 12286083
If you are trying to get values from the URL (with the GET form method)

You should be using $_GET or $HTTP_GET_VARS

and not $HTTP_SESSION_VARS

is that what you asking?
0
 
LVL 12

Assisted Solution

by:minichicken
minichicken earned 250 total points
ID: 12286096
or if you are using "post" as the form method you should use $_POST or $HTTP_POST_VARS
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12286099
Are you sure this  $HTTP_SESSION_VARS['$sess_val'] is correct souldn't it be
 $HTTP_SESSION_VARS[$sess_val]
'$sess_val' is the string $sess_val not the content of $sess_val
0
 

Author Comment

by:radical_mit
ID: 12286260
Hi minichicken,
sorry, I did not clean up the code completely, I have been tring all diffenet way.
When I change the posted PHP to $_GET I then get on the select Page
select2.php?p-400=w&p-401=w&p-402=y&p-403=n&p-404=w&p-405=w&p-406=w&p-407=w&p-408=w&p-409=w&p-410=w&
p-411=w&p-412=w&p-413=w&number_of_sele=
which is want I would expect. But then when I try to read it, via
while (list($key,$value) = each($_GET));
echo "$key = $value"
for example, there is no output
Where I would have expected to get something like p-401=w for example.

Tim
0
 
LVL 12

Expert Comment

by:minichicken
ID: 12286480
i think you should try this to see if there any values posted at all:

print_r ($_GET);
 or
print_r ($_POST);

if you get an output like : Array ([p-400] => w , [p-401] => w , .....)

if no value is passed at all then: Array()
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:radical_mit
ID: 12286527
Hello,
I get Array ( [p-400] => w [p-401] => w [p-402] => y [p-403] => n [p-404] => w [p-405] => w [p-406] => w [p-407] => w [p-408] => w [p-409] => w [p-410] => w [p-411] => w [p-412] => w [p-413] => w [number_of_sele] => ) =
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 250 total points
ID: 12286571
If you are using each make sure the array pointer is set to the start. So try:
reset($_GET);
while (list($key,$value) = each($_GET));
0
 

Author Comment

by:radical_mit
ID: 12286675
hello,

I tried the reset($_GET); i still do not see any of the url line.

I have added

echo $key . "=" . $value . " <b>" ;
echo '$key' ;
echo "$key" ;

just to complete the output, I then get the third one $key outputed to the screen

Tim
0
 
LVL 12

Expert Comment

by:minichicken
ID: 12286681
I think hernst42 is right, you will need to reset the array. Look at this example straight from the PHP manual.

************************************************

<?php
$fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry');

reset($fruit);
while (list($key, $val) = each($fruit)) {
    echo "$key => $val\n";
}
?>  

Outputs:

a => apple
b => banana
c => cranberry
 
 


After each() has executed, the array cursor will be left on the next element of the array, or past the last element if it hits the end of the array. You have to use reset() if you want to traverse the array again using each.

Because assigning an array to another variable resets the original arrays pointer, our example above would cause an endless loop had we assigned $fruit to another variable inside the loop.
0
 

Author Comment

by:radical_mit
ID: 12287115
Hi Both,
Thanks for that, its looking a lot better, I will give more info later
Tim
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now