Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide Value of Combo Box 1

Status
Not open for further replies.

stoolpigeon

Programmer
Aug 1, 2001
309
US
I have a page that has a drop down combo box w/a list of names. The value of each selection on the box is the employee i.d. that goes w/the name. I need that i.d. to run a query on the person that is chosen by the user.

But I don't want someone to be able to use View Source to see those i.d.s.

Is there a way that I can 'hide' that information?

(sorry if this is more of an html question than a php question- I've posted it here because I create the drop down box dynamically from a query in php)

Thanks for any help,
Ron
 
o.k. - hiding it wont work- silly question from the start.

But what do I do? I want to move the results from one query to another page so I can use them again w/out the user being able to access some of the information that I need.

Maybe a session variable?

Any advice would be welcome.

Thanks,
Ron
 
depending on the value needed for the query, would just the name work? Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
I guess I feel like I'm lacking information... but regardless of what you mean, it shouldn't be too tough.

A session variable is one approach, and probably your best. Though I'm always too lazy for session variables myself, so lets see what else you could do.

First let me get this straight, page 1, someone enters their name or selects it from a drop down box, page 2, this name is used to query the database and get the id, page 3, you want the id passed here?

That seems like an odd flow, and I'd say just skip page 2 and do the query on page 3, so I'm guessing there's more to it.

But if that is what you want, then just make a
Code:
<input type=hidden name=id
value=$result_from_query>
and make sure to use post as the method on your form... Don't forget the values will be available if someone viewed the source of the page, but for most applications that's hidden enough.

-Rob
 
No- unfortunately. I am using the value to look up an employee of the company and I need to be sure that it I use a unique attribute for the query.

What I am trying right now is registering a session variable and then filling it as an array as I make the drop down box- then I have the value come from my counter in the code- so I end up w/a multi dimensional array that is available on my next page. It looks a little like this:
Code:
for ($i=0;$i<$comborow;$i++)
{
  $comdat = pg_fetch_array($rs,$i);
  $mgr_list[$i] = $comdat;
  $combo .= &quot;<option value=$i>$l\t$f&quot;;
}
I left out some but this gives the idea. $mgr_list is a session variable. It is now an array w/$i number of elements- each of which is an array from my recordset.

When the data is sent to the new page I just get it like this
Code:
$nmgr = $mgr_list[$combonm][&quot;emp_id&quot;];
($combonm is the name of the drop down box - select thing)

This seems to work o.k. Though I am having a bit of trouble getting rid of $mgr_list. session_unregister does not seem to be working. When I do
Code:
session_unregister(&quot;mgr_list&quot;);
and then I echo $mgr_list it still returns 'array'. I want it gone. I'm not real familiar w/php (if you couldn't guess) but I'd like to destroy this variable once I'm done as this seems a good thing to do.

 
Thanks skiflyer,

I just found unset- tested it and it worked- then I saw your post. I need to do more reading. I like the function list but sometimes the explanations are over my head- I'm having a tough time finding something in the middle.

&quot;PHP and PostgreSQL Advanced Web Programming&quot; has 2 pages on sessions. Based on the title I thought I'd get more detail. It doesn't even scratch the surface. Other stuff is over my head. I'll keep poking around until I find something that works for me.

I am teaching myself Linux Sys Admin, PostgreSQL Admin, Apache Admin and PHP while programming our companies time & attendance system in PHP. I'm just getting the thing working and then hoping to plug all the holes later (unless I can find a better job first)

Thanks for the help.

Ron
 
I know the feeling, and I find these forums to be the perfect inbetween... just wanted to make sure you knew about the function list too.

And thanks for the stars, good luck :).

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top