Saturday, 15 September 2012

php - wpdb not inserting row into the table -


I have a form that is named, email and amp; Photo ... When I click submit, I want to put it in a post type that is called 'Contact', where the information and the image are presented as a featured image but it does nothing

My code

  & lt ;? 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 = & gt; $ yourname, post_status = & gt; 'publish', post_type = & gt; contact ', email = & gt; $ email, featured_image = & gt; $ myimage); $ Wpdb- & gt; Insert ($ table, $ data); }? & Gt; & Lt; Form action = "" method = "post" & gt; Your name: & lt; Input type = "text" name = "yourname" value = "" & gt; & Lt; Br> Your Email: & lt; Input type = "text" name = "email" value = "" & gt; & Lt; Br> Image: & lt; Input type = "file" name = "myimage" id = "" & gt; & Lt; Br> & Lt; Input type = "submit" name = "submit" value = "submit" /> & Lt; / Form & gt;  

Can I check if the line has been uploaded & amp; If one has been inserted and then redirects to a new URL after a few seconds, then resonate a message.

Check that the column $ data is passed to the database or in the form , Do not have method = "post" in enctype = "multipart / form-data" , try entering it.


No comments:

Post a Comment