Jump to content
Sign in to follow this  
Dave W

Ignoring Empty Fields

Recommended Posts

Hi,

I'm trying to tweak an existing web form to submit data to an FM7 DB using PHP. However, not all fields on the form are required and I cannot get the submit function to post to the database when any field is left empty. Does anyone have any ideas how to get it to post a new record when one of the fields is empty?

The setup of the page is pretty simple - the user populates the fields and then clicks submit. The page then posts the data to another page which runs it through a simple $_POST for each field. I've tried putting in a null (and 0) value in for the value of each field, but that doesn't seem to work. Thanks!

Share this post


Link to post
Share on other sites

exactly what error message are you getting?

after your insert or update use


$result = $record->commit();



if (FileMaker::isError($result)) {

	echo $result->getMessage();

}




to find out.



this may help too



$myFieldVal = isset($_POST['myField'])?$_POST['myField']:"My Default Value";

Share this post


Link to post
Share on other sites

Hi,

The error message is:

Notice: Undefined index: AAI in C:InetpubRAPhandle_form.php on line 143

The line is repeated for each field left blank (and the associated $_Post line number).

My goal is to simply have the fields left blank in the DB record, so the fields don't have default values. Thanks for the help (again)!

-Dave

Share this post


Link to post
Share on other sites

All fields have a default value. That value may be null, an empty string, 0, etc. But when the row is created something goes in the column.

I'm assuming that 'AAI' is the name of one of the fields and that the PHP Notice changes for each field. Using:


if(isset($_POST['AAI']){

    /* do something with $_POST['AAI'] */

}





Will stop the message but depending on how the rest of your page is written it may not be the problem with your submit (PHP Notices are informational only they don't halt or alter the how the code is processed code in any way.  They exist to let you know that php has run across something that may cause your code to not run as expected.).  



To fully troubleshoot your submit problem you need to know what the Filemaker error is after you perform the commit();  A couple of easy to miss gotchas that immediately come to mind are trying to set fields that are not on the layout you are using.  Filemaker's field validation is failing on one of your values.  



Knowing what your $_POST array contains might help you as well




print_r($_POST);




will tell you that.  Wrapping it in pre tags will make it a little more readable on the screen, although you can always just use view source to see the output with new lines in place.





The easiest way to set up and handle a simple web form submit for Filemaker is as follows:





/* For an Update */



$fields = $record->getFields();

foreach ($fields as $field){

	if (isset($_REQUEST[$field])) {

		$record->setField($field, $_REQUEST[$field]);

	}

}

$result = $record->commit();

 

/* For an Insert */



$layoutName = "myLayout";

$layout = $fm->getLayout($layoutName);

$insertVars = array();

$fields = $layout->getFields();

foreach ($fields as $fieldName => $fieldObject){

	if (isset($_REQUEST[$fieldName])) {

		$insertVars[$fieldName] = $_REQUEST[$fieldName];

	}

}

$newRecord = $fm->createRecord($layoutName, $insertVars);

$result = $newRecord->commit();



/*

it's a good idea to error check every major transaction so in either case followup with 

*/



if (FileMaker::isError($result)) {

    echo $result->getMessage();

}

This requires that all of your Filemaker Field names contain only letter, numbers, and/or underscores. No spaces or other characters (which IMHO is what you should be doing anyway). It also requires that each (or ) tag's "name" attribute contain the name of the Filemaker field it represents. I used $_REQUEST instead of $_POST because it contains both $_POST and $_GET values (i.e. works with both POST and GET html forms)

Edited by Guest
one more thing

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • By Richard Carlton
      In this Coaches' Corner tip, Richard Carlton challenges you to go learn how to use RESTful services!
      Get up to speed with the FileMaker Pro 16 Video Training Course! 
      Top Rated Course by FileMaker Expert, Richard Carlton.  
      http://learningfilemaker.com/fmpro16.php
      Experience Richard's dynamic and exciting teaching format, while learning both basic, intermediate, and advanced FileMaker development skills. With 27 years of FileMaker experience and a long time speaker at FileMaker's Developer Conference, Richard will teach you all the ins and outs of building FileMaker Solutions.  The course is 50 hours of video content!
      Richard has been involved with the FileMaker platform since 1990 and has grown RCC into one of the largest top tier FileMaker consultancies worldwide. 
      Richard works closely with RCC's staff: a team of 28 FileMaker 
      developers and supporting web designers. He has offices in California, Nevada, and Texas.

      Richard has been a frequent speaker at the FileMaker Developers Conference on a variety of topics involving 
      FileMaker for Startups and Entrepreneurs, and client server integration.

      Richard is the Product Manager for FM Starting Point, the popular and most downloaded free FileMaker CRM Starter Solution.

      Richard won 2015 Excellence Award from FileMaker Inc (Apple Inc) for outstanding video and product creation, leading to business development.

      RCC and LearningFileMaker.com are headquartered in Santa Clara, CA.

      http://www.rcconsulting.com/
      Please feel free to contact us at support@rcconsulting.com
      If you want to explore building iOS apps for iPhone or iPad and deploying those out to the Apple App Store.
       
      Here is a video introduction to our iOS App Training https://www.youtube.com/watch?v=cVxQe_yAshw
      Looking for FM Starting Point free software download: http://www.fmstartingpoint.com
      For More Free FileMaker Videos Check out http://www.filemakerfree.com
      Visit http://www.learningfilemaker.com for all facets of FileMaker Award Winning Video Training.
      Please Visit Our Channel: https://www.youtube.com/user/FileMakerVideos Please Subscribe While There.

      Please Comment, Like & Share All of Our Videos.

      Feel Free to Embed any of Our Videos on Your Blog or Website.
      Follow Us on Your Favorite Social Media
      https://www.facebook.com/FileMakerVideos
      https://twitter.com/filemakervideos
      https://plus.google.com/+FileMakerVideos/videos

      Filemaker Pro 16 Training Videos
      FileMaker 16 Videos
      Filemaker Pro 16 Video Course
      #FileMakerVideos
      #FileMakerTrainingVideos
      #WhatisFilemaker16
      #FilemakerPro16Training
      #Filemaker16VideoTutorial
      #FilemakerPro16Videos
    • By docasar
      Hello,
       
      I am trying to connect to our current database with our shipping company so I can update the status of the delivered orders. To do that, I am currently using insert from URL and then parse the code to extract the info I need. However, I believe there should be a cleaner and safer way to do it using webservice.
      So I downloaded the documentation and looks very straightforward to set and I have been able to set up the POST and send it getting the data as XML using POSTMAN (as very well explained here:  http://www.filemakerprogurus.com/filemaker-api-integration-salvatore-coleangelo/ ) and also in the great post by luminfire https://luminfire.com/2017/06/12/curling-filemaker-16/.
      However, when I try the same parameters on my script in filemaker, I get all the time an error saying that something like  "Entry XML Schema/template it is not loaded correctly". Following the documentation of the API I see that on Postman I need to insert on the Body RAW some kind of code that looks like this: 
      <?xml version='1.0' encoding='UTF-8'?>
      <SeguimientoEnviosRequest xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='SeguimientoEnviosRequest.xsd'>
      <Solicitante>x</Solicitante><Dato>xxxxxxxxxxxxxxxxx</Dato>
      </SeguimientoEnviosRequest>
      but I don't know which settings I have to do on my script to make the call work.
      Any suggestions as to where to put this info so the can be passed with the CURL? I am a bit desperate now because I see the amazing possibilities that the interaction with the web service may bring but I can find a way to make it work...
      Thanks a lot for your always invaluable support!!
    • By jpons
      Hi,
      I want to enable the Cloud REST API, but I am afraid that I "dismissed" the notification message that allowed me to do so. How can I enable the RESP API on my cloud instance?
      Thanks,
      -J
    • By JTSmith
      OK, I'm using FM16 and trying to figure out an API call.  I'm not an expert when it comes to APIs.
      I have a shopify store, and I can use Insert from URL to get the JSON info on each order.  I want to be able to "PUT" and upload parts of the order.  Every order has a "Note" field that I can add notes.  Per the shopify API documentation, to add an order note, you do the following:
      Add Note to order
      PUT /admin/orders/#{id}.json { "order": { "id": 450789469, "note": "Customer contacted us about a custom engraving on this iPod" } }  
      Can someone help me with what I put in the cURL options area?  Any help would be appreciated.  I think I have the URL and Target figured out.  Thank you!!
    • By Richard Carlton
      Setting Tax Rates in FM Starting Point | FMSP Videos | FileMaker 16 101 Training
      https://www.youtube.com/watch?v=uuV9jKW0TH8
      Most Recent Upload https://goo.gl/Dbn9fm
      Get up to speed with the FileMaker Pro 16 Video Training Course! 
      Top Rated Course by FileMaker Expert, Richard Carlton.  
      http://learningfilemaker.com/fmpro16.php
      Experience Richard's dynamic and exciting teaching format, while learning both basic, intermediate, and advanced FileMaker development skills. With 26 years of FileMaker experience and a long time speaker at FileMaker's Developer Conference, Richard will teach you all the ins and outs of building FileMaker Solutions.  
      The course is 50 hours of video content!
      Richard has been involved with the FileMaker platform since 1990 and has grown RCC into one of the largest top tier FileMaker consultancies worldwide. 
      Richard works closely with RCC's staff: a team of 28 FileMaker developers and supporting web designers. 
      He has offices in California, Nevada, and Texas.

      Richard has been a frequent speaker at the FileMaker Developers Conference on a variety of topics involving FileMaker for Startups and Entrepreneurs, and client-server integration.

      Richard is the Product Manager for FM Starting Point, the popular and most downloaded free FileMaker CRM Starter Solution.
      Looking for FM Starting Point free software download: http://www.fmstartingpoint.com
      Richard won 2015 Excellence Award from FileMaker Inc (Apple Inc) for outstanding video and product creation, leading to business development.

      RCC, Filemaker Videos, and LearningFileMaker.com are headquartered in Santa Clara, CA.
      http://www.rcconsulting.com/
      Please feel free to contact us at support@rcconsulting.com
      FileMaker Pro is simply a powerful software used to create custom apps that work seamlessly across iPad, iPhone, Windows, Mac, and the web
      Transform your business with the FileMaker Platform
      Free FileMaker Training Videos Channel https://www.youtube.com/user/FileMakerVideos
      50 Hour FileMaker Pro 16 Video Training Course-FileMaker 16 News-Online FileMaker 16 Training Videos
      https://www.youtube.com/watch?v=KpQqLLDcZ8I
      Playlist https://www.youtube.com/watch?v=KpQqLLDcZ8I&list=PLjTvUZtwtgBTMCfjM6LLwBAwGf_yXfvd_&index=13
      Top 10 New Features in FileMaker 16-FileMaker 16 News-FileMaker 16 Instructional Videos-FileMaker 16
      https://www.youtube.com/watch?v=urh8iHOCxkg
      Playlist https://www.youtube.com/watch?v=urh8iHOCxkg&t=130s&index=1&list=PLjTvUZtwtgBTMCfjM6LLwBAwGf_yXfvd_
      Sharing your Database with Other Devices and Users-FileMaker 16 News-FileMaker 16 Database Sharing
      https://www.youtube.com/watch?v=GF82vkYtCtA
      Playlist https://www.youtube.com/watch?v=GF82vkYtCtA&index=8&list=PLjTvUZtwtgBTMCfjM6LLwBAwGf_yXfvd_
      Introduction to FileMaker WebDirect 16-FileMaker 16 News-Online FileMaker 16 Training Videos
      https://www.youtube.com/watch?v=uaZKIpBjMAM
      Playlist https://www.youtube.com/watch?v=uaZKIpBjMAM&list=PLjTvUZtwtgBSVV1-4pFG4SHAhCIP3Yy-I&index=17&t=10s
      FileMaker Behavior Change-Go To Object-FileMaker 16 Video Training-FileMaker 16 News-FileMaker Video
      https://www.youtube.com/watch?v=MFwFjZem3AM
      Playlist https://www.youtube.com/watch?v=MFwFjZem3AM&index=15&list=PLjTvUZtwtgBQVDIUvoRkcvrMLi7sTZmj5
      A database management system (DBMS) is a computer software application that interacts with the user, other applications, and the database itself to capture and analyze data
       
      Official site provides the SDK, Developer's Guide, Reference, and Android Market for the open source project
      http://learningfilemaker.com/FIAS.html
      Video introduction to iOS App Training https://www.youtube.com/watch?v=cVxQe_yAshw
      Free FileMaker videos check out ...http://www.filemakervideos.com
      Download the FileMaker Pro 16 & FileMaker GO 16 for mobile devices training videos at http://www.learningfilemaker.com
      Download FileMaker Go 16 video training at http://learningfilemaker.com/FMGO-16/fmgo16.php
      Download FileMaker 16 Full Video Training Bundle at http://learningfilemaker.com/subscription.php
      FileMaker Video Training Review-FileMaker 16 Video Course Review-FileMaker Pro 16 101 Course Review
      https://www.youtube.com/watch?v=mF6Uor0KmKo
      Playlist https://www.youtube.com/watch?v=mF6Uor0KmKo&list=PLjTvUZtwtgBT8tNHuzF6cOKC_37zCTQl6&index=18
      Use FileMaker to create an app with the FileMaker Training Series
      FileMaker Pro is a cross-platform relational database application from FileMaker Inc.
      Please Comment, Like & Share Our Videos.
      Feel Free to Embed any of Our Videos on Your Blog or Website.
      Follow Us on Your Favorite Social Media
      https://www.facebook.com/FileMakerVideos
      https://twitter.com/filemakervideos
      https://plus.google.com/+FileMakerVideos/videos
      #WhatisFileMaker16
      #FileMakerPro16Training
      #FileMaker16VideoTutorial
      #FileMakerPro16Videos
      https://www.youtube.com/watch?v=uuV9jKW0TH8&index=53&list=PLjTvUZtwtgBTMCfjM6LLwBAwGf_yXfvd_
      http://feeds.feedburner.com/SettingTaxRatesInFmStartingPointFmspVideosFilemaker16101Training
×

Important Information

By using this site, you agree to our Terms of Use.