We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 35843
    • 34 Posts
    hey

    having a bit of a problem with my form. For some reason, when I submit the form, I get the error

    Fatal error: Call to undefined function TestimonialForm2Db() in /assets/snippets/eform/eform.inc.php on line 380

    testimonial_block
    [!eForm? &formid=`TestimonialForm` &subject=`Testimonial Submission Form` &from=`[email protected]` &tpl=`testimonial_form` &eformOnBeforeMailSent=`TestimonialForm2Db` &sendAsHtml=`1` &to=`[email protected]` &report=`testimonial_report` &thankyou=`whatYouThinkThankYou`!]
    


    [+validationmessage+]
      <div class="form-wrapper">
      <form name="TestimonialForm" id="TestimonialForm" enctype="multipart/form-data" action="[~[*id*]~]" method="post">
    					<input name="formid" type="hidden" value="TestimonialForm" />
    					
    					<div class="column first">
                                                   <label for="firstname">First Name:<span class="red">*</span><br /></label><input type="text" id="firstname" name="firstname" value="" eform="First Name::1:" />
                                            </div>
                                            <div class="column second">
                                                  <label for="lastname">Last Name:<span class="red">*</span></label><br /><input type="text" id="lastname" name="lastname" value="" eform="Last Name::1:" />
                                            </div>
                                            <div class="column third">   					
                                                  <label for="email">Email:<span class="red">*</span></label><br /><input type="text" id="email" name="email" value="" eform="Email::email:1" />
                                            </div>
    
                                            <div class="clear"><!-- --></div> <br />             
                                                 <div class="column first">
                                                 <label for="golfcourse">Golf Course:<span class="red">*</span></label><br /><input type="text" id="golfcourse" name="golfcourse" value="" eform="Golf Course::1:" />
                                           </div>
                   
                                           <div class="column second">
                                                 <label for="city">City:<span class="red">*</span></label><br /><input type="text" id="city" name="city" value="" eform="City::1:" />
    			        	 </div>					 
    				 	<div class="column third">
                                                 <label for="state" >State:<span class="red">*</span></label><br /><input type="text" id="state" name="state" value="" eform="State::1:" />
                                            </div>
    			
    			               <div class="clear"><!-- --></div> <br />
               			      <div class="column first">
                                                  <label for="phone">Phone</label><br /><input type="text" id="phone" name="phone" value="" eform="Phone::1:" />
                                          </div>
                                          <div class="clear"><!-- --></div><br />          
                                            	   <label for="message">Message:</label><br /><textarea id="message" name="message" rows="10" cols="40" eform="Message::0:" ></textarea>
                  
                   
    				      <div class="clear"><!-- --></div> <br />
                                                       <label style="text-align:left;" for="photo">Upload Photo:</label><br /><input type="file" id="photo" name="photo" value="" eform="Photo:file:0" />
                        
                        <div class="clear"><!-- --></div><br />
                          <input type="submit" value="Submit" />
    </form>
    


    TestimonialForm2Db
    <?php
    function TestimonialForm2Db( &$fields )
    	{
    		// Bring needed resources into scope
    		global $modx, $table_prefix;
    
    		// Init our array
    		$dbTable = array(); // key = DB Column; Value = Insert/Update value
    
    		// Insert field/value pairs to insert/update in our table
    		$dbTable[firstname] = $fields[firstname];
    		$dbTable[lastname] = $fields[lastname];
    		$dbTable[email] = $fields[email];
    		$dbTable[golfcourse] = $fields[golfcourse];
    		$dbTable[city] = $fields[city];
    		$dbTable[state] = $fields[state];
    		$dbTable[phone] = $fields[phone];
    		$dbTable[message] = $fields[message];
    		$dbTable[photo] = $fields[photo];
    
    
    		// INSERT - $dbQuery = $modx->db->insert( $dbTable, $table_prefix . 'insertTableName' );
    		// UPDATE - $dbQuery = $modx->db->update( $dbTable, $table_prefix . 'updateTableName' );
    		// DELETE - $dbQuery = $modx->db->delete( $table_prefix . 'deleteFromTableName', 'some_field = 1 AND name=\''.$dbTable[name].'\'', '' );
    		// etc...
    				
    		// Run the db insert query
    		$dbQuery = $modx->db->insert( $dbTable, 'testimonial' );		
    
    		return true;
    	}
    	// Return empty string
    	return '';
    ?>
    



    Any thoughts, everything looks okay. not sure what could be wrong. Could it be the file upload.

    Thanks
    Riz

      • 4041
      • 788 Posts
      Looks like there is a misspelling in the snippet call:
      &eformOnBeforeMailSent
      should be
      &eFormOnBeforeMailSent
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 35843
        • 34 Posts
        thanks breezer, that was one of the problems, the second one was also the fact that the form didn't know to send to the database. lol

        [!TestimonialForm2Db!]

        oh bother