php - wpdb not inserting row into the table -


i have form allows input of name ,email & photo...when click on submit want insert row posttype called'contact' info submitted form , image featured image nothing

my code

<?php   if (isset($_post['submit'])) {           $yourname=$_post['yourname'];      $email=$_post['email'];      $myimage=$_post['myimage'];          include_once('../../../wp-config.php');     global $wpdb;     $table = 'wp_posts';     $data  = array(     post_title=>$yourname,       post_status=>'published',      post_type=>'contacts',       email=>$email,     featured_image=>$myimage     );     $wpdb->insert( $table, $data);  }      ?> <form action="" method="post">          name: <input type="text" name="yourname" value=""> <br>          email:  <input type="text" name="email" value=""> <br>          image: <input type="file" name="myimage" id=""><br>             <input type="submit" name="submit" value="submit" />            </form> 

is there way can check if row uploaded & echo message if insert done , redirect new url after few seconds.

check if columns passed on $data exists in database or in form don't have method="post" enctype="multipart/form-data", try insert this.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -