The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
Some Demo Coded Pages would be nice - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17) +--- Thread: Some Demo Coded Pages would be nice (/showthread.php?tid=2025) |
Some Demo Coded Pages would be nice - Question Guy - Jun 9th, 2012 I have finally gotten the API functions working in a test localhost environment. But the way the documentation is written leaves an actual form as a "theoretical" construct codewise. It would have been helpful to actually include some fully coded samples as demo examples of a properly coded form. I have the API functions, for the most part, working where the external form page is being written into the FormTools database. I have a form page and a thank you page written in php. When the form page is filled out and the Submit button is used the data does wind up inserted into the Form Tools database. But on the Submit action the form "disappears" and I have nothing but a white page that does not step through to the "thank you" page where the session close code is waiting. I have to manually enter the url of the thank you page to close the session and be able to test the form page again. I am going to include the code for the 1) external form using the API and 2) the thank you page that never shows up. Hopefully, someone can point out my coding error. The form is identified as ID "6" in my Admin panel. Status is ONLINE (accepting submissions). Form type: External All Clients can Access Submission type. Code (API) Form Url checks out correctly Access: Public PHP Code: <?php This test form DOES Insert the Field values into my Form Tools form. But this page called "vipcontestform.php" turns white with no html code generated past the API code at the top. It does not redirect to the "thanks.php" test page codes as such below: PHP Code: <?php require_once('formtools/global/api/api.php'); This even sends emails. But I cannot get the form pages to step through after submission to the thanks.php which kills the user session. I'd appreciate some eagle eyes looking at this! RE: Some Demo Coded Pages would be nice - michatmaster7 - Jun 11th, 2012 It took me awhile to find this old post, so I don't blame you for not searching the forums. Can you try this and see what it says? (May 5th, 2011, 1:12 PM)Ben Wrote: Also one tip I should have mentioned: if you haven't already done so, add this to your /global/config.php file: Also - the name and id attributes of your submit button do not match what you've told FormTools. That could be causing an error. You told FT it was "Send_Guess" - but you've got the HTML as "Send Guess" RE: Some Demo Coded Pages would be nice - Question Guy - Jun 12th, 2012 Thank you for your suggestions, Ben and Michatmaster7, but I have exactly the same problem as before. Ben: that line into my config.php file as in $g_table_prefix = "ft_"; $g_default_error_reporting = 2047; does not produce visible errors. It makes no difference. I get the same white page output with no html code produced after the Submit button is clicked. Whatever error I would hope to see made visible does not happen. The browser stays on the same external form page only the page this time around is empty of all code. And it never steps to the the "thank you" page -- my test "thanks.php" I have tried giving this page the full http url but it makes no difference in the outcome. I am still hung up on the original form page after Submit except that it does not produce html code at all. HOWEVER, the form gets Written and it is Sending Emails from the Template I set up! So, the Email configuration seems to be working perfectly. I just need to get this re-direct to a Thank you page or Any page working. RE: Some Demo Coded Pages would be nice - michatmaster7 - Jun 12th, 2012 Have you changed the submit button code as I suggested? Side note: the attribute value for the form tag's method attribute should be lowercase to comply with XHTML. Also - often times this can happen if there is a coding problem with one of the HTML e-mail templates you're using. Can you post that code here, as well? RE: Some Demo Coded Pages would be nice - Question Guy - Jun 12th, 2012 Hello michatmaster7, thanks for taking a look again and responding. Yes, you are correct about the matching of the Submit button names. Actually, in the last version of the code they do match. And in subsequent testing I simply removed spacing so that there was no need to place an Underline as a gap filler. So the the name for the Submit button became "sendguess". I have just gone through all the steps for another form and it is now Complete and Online. After going through the Initialization process I cam back and changed the PHP head in my new form just called "vipform.php" <?php require_once('formtools/global/api/api.php'); $fields = ft_api_init_form_page(7); $params = array( "submit_button" => "sendmyguess", "next_page" => "nothanks.php", "form_data" => $_POST, "finalize" => true ); ft_api_process_form($params); ?> Just as extra information I added the form name and id from the Form settings Name itself: <form name = "BigContest" id= "BigContest" action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST"> The "no thanks" PHP file is renamed and I use this code as the Submit <p>Submit <input type="submit" name="sendmyguess" id="sendmyguess" value="Submit" /> Same old nothing. This new form submits to itself, stays there, does not move on to "nothanks.php". What I notice is that FormTools wants to use the Submit Button value and create and save a field value for it. I removed this field from my previous Form. This time, in this new test form I KEPT the SUBMIT field and am allowing the Post to send "Submit" to a field for each Post. Here's the html email template from this new form: <p> There has been a submission made through your form, {$FORMNAME}: </p> <table cellpadding="0" cellspacing="1"> <tr> <td style="font-weight: bold">ID</td> <td>{$SUBMISSIONID}</td> </tr> {if $ANSWER_id} <tr> <td style="font-weight: bold">Id</td> <td>{$ANSWER_id}</td> </tr> {/if} {if $ANSWER_fname} <tr> <td style="font-weight: bold">Fname</td> <td>{$ANSWER_fname}</td> </tr> {/if} {if $ANSWER_lname} <tr> <td style="font-weight: bold">Lname</td> <td>{$ANSWER_lname}</td> </tr> {/if} {if $ANSWER_city} <tr> <td style="font-weight: bold">City</td> <td>{$ANSWER_city}</td> </tr> {/if} {if $ANSWER_email} <tr> <td style="font-weight: bold">Email</td> <td>{$ANSWER_email}</td> </tr> {/if} {if $ANSWER_guess1} <tr> <td style="font-weight: bold">Guess1</td> <td>{$ANSWER_guess1}</td> </tr> {/if} {if $ANSWER_guess2} <tr> <td style="font-weight: bold">Guess2</td> <td>{$ANSWER_guess2}</td> </tr> {/if} {if $ANSWER_guess3} <tr> <td style="font-weight: bold">Guess3</td> <td>{$ANSWER_guess3}</td> </tr> {/if} {if $ANSWER_modified} <tr> <td style="font-weight: bold">Modified</td> <td>{$ANSWER_modified}</td> </tr> {/if} {if $ANSWER_ip} <tr> <td style="font-weight: bold">Ip</td> <td>{$ANSWER_ip}</td> </tr> {/if} {if $ANSWER_password} <tr> <td style="font-weight: bold">Password</td> <td>{$ANSWER_password}</td> </tr> {/if} {if $ANSWER_sendmyguess} <tr> <td style="font-weight: bold">sendmyguess</td> <td>{$ANSWER_sendmyguess}</td> </tr> {/if} <tr> <td style="font-weight: bold">Last modified</td> <td>{$LASTMODIFIEDDATE}</td> </tr> <tr> <td style="font-weight: bold">IP Address</td> <td>{$IPADDRESS}</td> </tr> </table> <p> Submission made: {$SUBMISSIONDATE} </p> RE: Some Demo Coded Pages would be nice - Question Guy - Jun 13th, 2012 So, I finally took this online and it WORKS! Even though my Test Email function on my localhost worked, apparently something in the FormTools configuration can't handle localhost email. The localhost environment always sends emails correctly out to the internet but the Test Email function in FormTools Settings is apparently disconnected from the actual process for a Live External Form. Once I installed this ONLINE at a server then the form advanced to the "thank you" page! NOW, I am trying to solve an API Form validation problem. In a nutshell: As soon as I added PHP Validation rules into my form that specified that 3 of my fields had to have a length of 6 characters but no greater than 6 then the PHP errors returned IF any of those fields were NOT filled out. But, I am not running a REQUIRED rule on those fields. I simply want any values, if entered, into those 3 fields to be no less than 6 characters in length and no more than 6 characters in length. But this Rule is now making each of those fields REQUIRED on this form submission. What the PHP should be saying as part of the rule is that "IF there is a Posted Value for this field then the Following Rule on Minimum and Maximum Length ought to be Applied ELSE this particular Rule does not run for this field". Here is the script that is now Reporting an Error when No Value is Posted into the Guess1, Guess2, Guess3 field. It also contains a Login test script at the top. PHP Code: <?php RE: Some Demo Coded Pages would be nice - Question Guy - Jun 13th, 2012 OKAY, another problem SOLVED. I have made the PHP server side validation Conditional for the 3 fields that were giving me problems because attaching character length validation code to those 3 fields was making them Required. I have modified the code to the following so that the form will allow the user to simply leave the fields blank when the form is processed after Submit using the external form API. Here is the code that solves the problem for me. PHP Code: <?php RE: Some Demo Coded Pages would be nice - michatmaster7 - Jun 13th, 2012 Wow, you're on a roll! As I was reading your replies i was thinking to myself how I would respond to each of them, until I saw your next reply, where you fixed it...lol. I wouldn't have used the if statements quite like that in the validation, but if they work, then don't change them! Ha! What I guess I wasn't understanding from your OP is that the form you were testing was not actually on a live server. I had that problem once before while running XXAMP. (XAMPP?). But I digress. As you've discovered, FT will not correctly process things unless it's on a live server. I'm sure with some tweaking, you could get it to, but that's WAY outside my area of expertise. I'm happy that you got everything working ![]() PS - I have a medium expertise with the PHP validation, if you get stuck again. I've had my share of issues with it, as well. The only thing I CAN'T do (yet), is custom expressions. That's completely gibberish to me. |