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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a new page based on the selected item 1

Status
Not open for further replies.

GKChesterton

Programmer
Aug 17, 2006
278
US

I have got a PHP page that returns MySQL query results as a table:
[tt]
Item A Description of Item A
Item B Description of Item B
Item C Description of Item C
Item D Description of Item D
... dozens of records
[/tt]
Now I want the user to be able to select any Item and see a page with all the details on that Item. I can't figure out how to pass the Item identifier as a variable. Can I make each field in the left column a link and pass it in the href URL, using header() maybe? Or set a $_SESSION variable? Or is a Form somehow invoked? And why is this so hard to figure out with the whole Internet and two fat books available?!




[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
UPDATE: I just found cURL is available on my ISP
CURL support: enabled
CURL Information:
libcurl/7.12.1 OpenSSL/0.9.7a zlib/1.2.1.2 libidn/0.5.6

Probably I have to learn how to use that ...

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
Okay, I passed the item ID. I just tacked ?item=$item onto the <a href=nextpage.php and then used $item = $_GET['item']; on the next page's script. If anyone wants to propose a better method, please go ahead ... at least I can keep developing for now!

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
your method sounds fine unless you want to keep the url clean, in which case you would normally use buttons and a form or, if javascript is available, use links or onclicks() to fill a hidden form programmatically and then to post the form to the server. all methods are straightforward.
 
Javascript! That sounds likely. Haven't used it before but hey, now I could say I have. But I really don't mind a 'dirty' URL, it's just an index number.

And I will use a server var for the current SQL string that brought up the scrollable list of Items, so when the user leaves the detail view she is looking at the same list as before.

The plain form idea leaves me with some questions, but, it's off to church --- maybe I'll fiddle with it.

Thanks, jp.

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
Code:
<?php
session_start();

if(!session_is_registered('username')){
//the session variable isn't registered, send them back to the log[s][/s]in page
header( "Location: [URL unfurl="true"]http://localh[/URL][s][/s]ost/login.htm" );
}

I found this bit of code and it works.

BUT ...

I can't figure out how to get the value of $username on this page. It's registered, good it exists ... but what IS it?


[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
that code is old, and intrinsically incomplete as a full login script.

let's back up a bit. are you looking for a page protection script based on session management? if so, how do you want to store user names and passwords?

you should probably start a new thread for this - it seems unconnected with your previous thread on the despatch method.
 
Yes ... the common elements are (a) my need to keep variables from page to page and (b) my rampant ignorance.

GET is one method for passing a var and I have that going okay. I was waiting on putting user authentication in place, but I found a set of scripts for a simple security scheme. These also addressed session handling, so out of interest in that topic, I slapped 'em into place and enjoyed the benefits. (Until I moved it all to the ISP ... that's the other thread jpadie's been reviewing! But let's keep the troubleshooting arena on my localhost setup for sanity.)

With the security code, I discovered I could see if a session var is registered, but it seems I can't produce the value.

I've tried passing SID and PHPSESSID, and using $_SESSION, and as the old Cajun said, I feel like a blind dog in a meat house ... there's bound to be sustainance around here. One thing I haven't tried yet is writing to cookies, which is probably the obvious.

If anyone wants to suggest a good subject for the next thread ...

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
keeping elements from page to page: sessions are your friend
for the login script: start a new thread telling us how you want to manage your user names and passwords (i.e. access control) and we'll see what we can do. Most of us have prebuilt logon scripts for countless sites that can probably be easily adapted for your use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top