unable to insert data into wordpress db using form

When i click on submit it doesn’t create new posts in the posttype. It just refreshes the page.The below is a pagetemplate assigned to page.

    global $wpdb;
    $wpdb->insert( 'contacts', array('post_title'=>$_POST['name'],'email'=>$_POST['email']));
<form method="post" action="">
<input type="name" id="inputName" placeholder="Name">
<input type="email" id="inputEmail" placeholder="Email">
<button type="submit">SUBMIT</button>

Source: wpdb

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.