PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 20th, 2004, 07:28 PM
m0untaind0g m0untaind0g is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 18 m0untaind0g User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 10 sec
Reputation Power: 0
Send a message via AIM to m0untaind0g
PHP and Forms

Hi there,
I have a script where the administrator of the site can add / edit / delete records. Here's how its works: basically the admin selects a user from a drop down menu and hits submit. This goes to a page where it queries the DB and returns some basic info - name, email address and so on (hub page).

For example: You selected Jim Shoe - his email address is gym@jim.com. This part works fine.

The problem I am having is when the user returns to this "hub" page from editing a record or adding record it comes back blank, none of 'Jim's' info is showing. How can I get to show the information again? Are sessions and cookies the answer? Any insight on how to do this is appreciated.

Thanks Craig

Reply With Quote
  #2  
Old March 22nd, 2004, 10:20 AM
pentapenguin pentapenguin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 51 pentapenguin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 7 sec
Reputation Power: 6
It looks like the "hub.php" page originally gets some info from a form.
Like this: hub.php?id=1&name=Jim+Shoe
However, after editing, no data gets sent back to the "hub.php" page so the script doesn't know what to do.
On the edit page you need to have the form look something like this:
<form action="edit.php?id=1&name=Jim+Shoe">
.................................................. .............
</form>

(Obviously you need to change the variables.)
That way the data is preserved.

Reply With Quote
  #3  
Old March 22nd, 2004, 08:15 PM
m0untaind0g m0untaind0g is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 18 m0untaind0g User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 10 sec
Reputation Power: 0
Send a message via AIM to m0untaind0g
would using sessions be another option?

Reply With Quote
  #4  
Old March 23rd, 2004, 04:51 AM
Spongy's Avatar
Spongy Spongy is offline
Alternately High
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Hilversum, Netherlands
Posts: 223 Spongy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 56 m 41 sec
Reputation Power: 5
Send a message via MSN to Spongy
It wouldn't be my choice for this matter. When you want to store logindata for example, then it's easy to use sessions. But believe me that for your problem the solution of pentapenguin is the best and the most easy one.

Cheers,
__________________
Work to live, don't live to work

Reply With Quote
  #5  
Old March 23rd, 2004, 11:16 AM
m0untaind0g m0untaind0g is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 18 m0untaind0g User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 10 sec
Reputation Power: 0
Send a message via AIM to m0untaind0g
My forms are pretty long so it would be a major pain to pass all that data in the URL.

<form action="edit.php?id=1&name=Jim+Shoe">

Honeslty I would like to use SESSIONS.

On the page I would like to send back to "hub page" I have this code:
<p><a href='client_info.php?user_id=$row[0]$user_id&?=$PHPSESSID'>Back</a> to Client Management Page</p>

What do I need to do on this "hub page" to make the date reappear?
Thanks - CH

Reply With Quote
  #6  
Old March 23rd, 2004, 02:08 PM
Spongy's Avatar
Spongy Spongy is offline
Alternately High
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Hilversum, Netherlands
Posts: 223 Spongy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 56 m 41 sec
Reputation Power: 5
Send a message via MSN to Spongy
Quote:
Originally Posted by m0untaind0g
Code:
<p><a href='client_info.php?user_id=$row[0]$user_id&?=$PHPSESSID'>Back</a> to Client Management Page</p>


First of all... You do some really strange things here. I'm not really sure what you are thinking but this will never work.
You say that the post-var user-id has the value of $row[0].
Does it have the value of $row[0] combined with the value of $user_id?
It's more readable to make another var which combines these two vars.
PHP Code:
 $newvar $row[0].$user_id

Then you call $PHPSESSID, but how are you supposed to get it out of the string? It's not attached to a post-var, so no chance of getting it! In my opinion, this line should look like this:
Code:
<a href='client_info.php?user_id=$newvar&sess_id=$PHPSESSID'>Back</a> to Client Management Page

No extra questionmark is needed. And I really don't want to encaurage you, but if you make this kind of misstakes a lot, I advice you not to start with sessions. Try some tuto's first for basic PHP.
No offense of course, but this looks like a beginner...
Hopely I could help,
Cheers

Reply With Quote
  #7  
Old March 24th, 2004, 06:36 AM
tobycloud tobycloud is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Near Albany NY
Posts: 27 tobycloud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to tobycloud Send a message via AIM to tobycloud
Post Re: PentaPenguin

Quote:
Originally Posted by pentapenguin
<form action="edit.php?id=1&name=Jim+Shoe">
.................................................. .............
</form>


Additionally you could do this:

<form action="edit.php">
.................................................. .............
<input type="hidden" name="id" value="1">
<input type="hidden" name="name" value="Jim Shoe">
</form>

It's a little more typing, but eh, it works.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP and Forms


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway