dawber
Posts: 25
|
Posted: 08/06/2005, 12:42 PM |
|
I have a few screens working as expected:
In the "Add Record" screen the user can insert a new record into the database.
In the "Edit Record" screen the user can select the Key of an existing record
(from the record listings) to edit a record in the edit section.
The record listings is sorted by default to show the latest record on top.
After a successful "Add Record", the user is redirected to the "Main" screen.
Now there is a request to:
1. Redirect the user to the "Edit Record" screen after a successful "Add Record".
2. Populate the edit section with the record that was just added in the "Add Record" screen.
3. Therefore, save the user one click by not clicking on the respective record in the listings.
It should be noted that there are multiple users on the system
and each of them could be doing an "Add Record".
It is quite possible that user A's latest record might not appear
on the top because user B's latest record was the most recent Add.
So, how do I:
a. Get the Key of the record that was just (successfully) added by this user.
b. So that I may pass that Key to the "Edit Record" screen.
|
|
|
peterr
Posts: 5971
|
Posted: 08/07/2005, 9:26 PM |
|
See:
- "Multi-Step User Registration" example in CCS Example Pack
- http://forums.codecharge.com/search.php?s_keyword=last+...g=2&s_forum[]=5
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
Damian Hupfeld
|
Posted: 08/09/2005, 4:11 AM |
|
Add an extra field to your table and store the UserID, UserLogin or some
other user identifier. Then display the most recent entry where
CCGetSession(UserID) equals this field value. Pretty easy.
regards
Damian Hupfeld http://www.nexthost.com.au/services.php
|
|
|
dawber
Posts: 25
|
Posted: 08/21/2005, 4:44 AM |
|
Quote peterr:
Peterr,
I looked at the examples mentioned above.
I am using PHP and MySQL.
I added the following code to the form "After Execute Insert" Event:
global $Redirect;
global $DB_c_connection;
if(!CCGetFromGet("F_p_PRIM_KEY",0)) {
$get_the_Latest_F_p_PRIM_KEY=CCDLookUp( 'last_insert_id()', 'T_Pa_1', '', $DB_c_connection;);
if (strpos($Redirect,"?") == false ) {
$Redirect = $Redirect."?F_p_PRIM_KEY=".$get_the_Latest_F_p_PRIM_KEY;
} else if (substr($Redirect,-1) == "?" ) {
$Redirect = $Redirect."F_p_PRIM_KEY=".$get_the_Latest_F_p_PRIM_KEY;
} else {
$Redirect = $Redirect."&F_p_PRIM_KEY=".$get_the_Latest_F_p_PRIM_KEY;
}
}
But it not make any difference.
The URL for the redirected page is same as before.
The Insert is done successfully.
When the redirected page loads, it does not contain the
&F_p_PRIM_KEY=
and the last inserted primary key
What did I do wrong?
|
|
|
peterr
Posts: 5971
|
Posted: 08/21/2005, 12:26 PM |
|
I don't know what's wrong, so you may need to some debugging. I can also recommend that you see how others implemented this: http://forums.codecharge.com/search.php?s_keyword=last+...g=2&s_forum[]=5
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
dawber
Posts: 25
|
Posted: 08/21/2005, 3:07 PM |
|
Peter,
I did some debugging:
For both "After Execute Insert" and "After Insert" events
I replaced my custom code mentioned in the above post with this simple 1 line :
exec('/tmp/zz_test/test1');
But I am surprised to find that this exec script did NOT get
executed for either "After Execute Insert" event or
"After Insert" event.
This test1 script simply contains:
#!/bin/bash
echo hi >> /tmp/zz_test/result.txt
To begin with, I had created an empty /tmp/zz_test/result.txt file.
The permissions are -rwxrwxrwx
The owner:group is apache apache
After both these events, the /tmp/zz_test/result.txt file has not
changed in any way. The date/time is the same as before and it
is still an empty file.
FYI, later when I run the same diagnostic (Server-Before Show-Custom Code)
for a Label in this same form - it works! The /tmp/zz_test/result.txt file
contains "hi" and its date and time stamp is updated.
I don't understand.
Why is the custome code in the 2 After Insert events not being executed?
|
|
|
peterr
Posts: 5971
|
Posted: 08/22/2005, 1:14 AM |
|
Possibly the insert itself never happens for some reason?
You could try contatcing the support to see if they have other ideas.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|