Editing database entry error

Home Forums Quform WordPress Editing database entry error

This topic is: not resolved
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #35871
    yenfa
    Participant

    Hello,

    So, I was trying to edit a database entry using a form. I managed to get to the part where the data is retrieved and reflected on the forms.

    But when I try saving or submitting the form, a critical error happens.

    I don’t want to share the URL in public, so if there’s an email I can write to, it would be great.

    Thank you!

    Attachments:
    You must be logged in to view attached files.
    #35877
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #35878
    yenfa
    Participant

    Hello Ally! Thank you for your assistance.

    I’ve tried to check my code but I don’t know anymore what’s wrong.

    
    add_filter('quform_post_process_2', function (array $result, Quform_Form $form) {
        global $wpdb;
        $table = 'wp9v_3_ked_fanlist_members';
     
        // The data to save/update
        $data = array(
            'name' => $form->getValue('quform_2_3'),
            'email' => $form->getValue('quform_2_11'),
            'website' => $form->getValue('quform_2_5'),
    		'country' => $form->getValue('quform_2_8'),
    		'code' => $form->getValue('quform_2_6'),
            'hide_email' => $form->getValue('quform_2_7')
        );
     
        $rowId = string($form->getValue('quform_2_11'));
     
        if ($rowId > 0) {
            $wpdb->update($table, $data, array('email' => $rowId));
        } else {
            $wpdb->insert($table, $data);
        }
     
        return $result;
    }, 10, 2);
    
    // update form
    
    add_action('quform_pre_display_2', function (Quform_Form $form) {
        if (!isset($_GET['e'])) {
            return;
        }
     
        global $wpdb;
    	$rowId = (string)$_GET['e'];
     
        $row = $wpdb->get_row($wpdb->prepare('SELECT * FROM wp9v_3_ked_fanlist_members WHERE email = %s', $rowId), ARRAY_A);
     
        if (!is_array($row)) {
            return $row['ID'];
        }
     
        // The form values to set
        // 
        $data = array(
            'quform_2_3' => $row['name'],
            'quform_2_11' => $row['email'],
            'quform_2_5' => $row['website'],
    		'quform_2_8' => $row['country'],
    		'quform_2_6' => $row['code'],
            'quform_2_7' => $row['hide_email']);
        
     
        $form->setValues($data);
    });
    
    
    #35881
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy