PHP2005 Posted March 31, 2005 Posted March 31, 2005 I am new at PHP, I am wonder if someone can help me. I have a problem with a web survey I am doing. The survey has 4 pages. But for some reason when I try to click continue each time, it is entering as a new information to a database. I guess I am doing the RecId incorrect. Here is the code Index.php <body> <form method="post" action="page1.php"> <input type="radio" name="have_program" value="Don't Know" > Don't Know </td> <input type="radio" name="have_program" value="Yes">Yes</td> <td width="10"><input type="radio" name="have_program" value="No" > No </td> </form> </body> ------ page1.php $create=new FX ($serverIP, $webCompanionPort); $create->SetDBData('survey.fp7',
Garry Claridge Posted March 31, 2005 Posted March 31, 2005 You can have only one Action. Not three: $createResult=$create->FMNew(); $createResult=$create->FMView(); $createResult = $create -> FMEdit(); If you wish to edit a record you obviously need the "recid". However you need to be able to get it from the database then assign it to a Form value to pass it to the next Action. For example: <input type="hidden" name="recid" value="<?=$recid?>"> To get the recid you may need to grab it after the FMNew() action. Good Luck. Garry
PHP2005 Posted April 12, 2005 Author Posted April 12, 2005 Hi Garry, thanks for the info. I did and it works using the FMfind(), and then I had another page with the FMEdit(), but my problem now is if I have several pages and wants to keep addinf to the same record. How should I do that instead have 1 page for FMfind() and 1 for FMedit(), since we can not hav etwo action at the same time. thank you, PHP2005
epicrecipe Posted April 13, 2005 Posted April 13, 2005 Garry meant you can only have one action for each FX instance. If I understand what you're doing, you should be able to have a single FX instance on each page: - page1.php - <form method="post" action="page2.php"> <input type="text" name="FirstName" /> <input type="text" name="LastName" /> <input type="submit" value="Continue to Page 2" /> </form> - page2.php - <?php // Field Vars from page1.php. (stripslashes helps clean data) @$FirstName = stripslashes($_POST['FirstName']); @$LastName = stripslashes($_POST['LastName']); // Create new FX Instance $Add = new FX($serverIP,$webCompanionPort); $Add->setDBData('database.fp7','layout'); // Add the record. $Add->AddDBParam('FirstName',$FirstName); $Add->AddDBParam('LastName',$LastName); $AddResult=$Add->FMNew(); // After all your error traps, you have a successful addition. Grab the recid. foreach($AddResult['data'] as $AddKey=>$AddRecord) // Get FileMaker Record ID $FMRecordID = explode('.',$AddKey); $recid = $FMRecordID[0]; ?> <form method="post" action="page3.php"> <input type="hidden" name="recid" value="<?=$recid?>" /> <input type="text" name="HomePhone" /> <input type="text" name="WorkPhone" /> <input type="submit" value="Continue to Page 3" /> </form> - page3.php - <?php // Field Vars from page2.php. @$recid = $_POST['recid']; @$HomePhone = $_POST['HomePhone']; @$WorkPhone = $_POST['WorkPhone']; // Create new FX Instance $Edit = new FX($serverIP,$webCompanionPort); $Edit->setDBData('database.fp7','layout'); // Edit Parameters. $Edit->AddDBParam('-recid',$recid); $Edit->AddDBParam('HomePhone',$HomePhone); $Edit->AddDBParam('WorkPhone',$WorkPhone); $EditResult=$Edit->FMEdit(); ?> If you want another action for FMFind(), just open another FX Instance and set your find parameters. If you want to keep adding to the same record, keep passing the recid via hidden fields and editing the record. You can also put all this logic in a single PHP page. Just change the form tags to <form method="post" action="script.php?mode=page2">. Then use if statements to check for $mode: <? if (isset($_GET['mode'])) { $mode = $_GET['mode']; } else { $mode = ""; } ?> and deliver content accordingly. Hope this helps! Shannon -=-=-
Recommended Posts
This topic is 7234 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now