How to create a custom form in wordpress

// create table in database ( must add prefix )


// create page to display form i was wrote code into front-page.php

                     





























  • if(isset($_POST['submitted'])) {

    global $wpdb;

    //print_r($_FILES['res']);
    $filename =  basename($_FILES['res']['name']);

    $path = get_template_directory()."/"."upload/resume/".$filename;
    //echo "
    ";
    $status = false;
    if(move_uploaded_file($_FILES['res']['tmp_name'], $path)) {
    $status = ture;
    }



    if($status == true) {

    $tablename=$wpdb->prefix.'resume';
    $date = date("Y-m-d H:i:s A");
    $data=array('name' => $_POST['contactName'], 'email' => $_POST['email'], 'path' => $filename, 'insdatetime' => $date);

    $wpdb->insert( $tablename, $data);
    echo "Inserted";

    global $wp;
    $current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );

    echo "";

    wp_redirect($current_url);

    unset($_POST);
    } else {
    echo "Not inserted";
    }

    }

    ?>


    // if you found header already sent error then you have follow further step

    // goto this location

    wp-includes/pluggable.php

    // open file and write code after
    ob_start();

    Comments

    Popular posts from this blog

    My new Jquery Plugin name is krDailog