|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
would using sessions be another option?
|
|
#4
|
||||
|
||||
|
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 |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
||||
|
||||
|
Quote:
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:
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 |
|
#7
|
|||
|
|||
|
Quote:
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. ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > PHP and Forms |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|