Created
October 1, 2015 16:31
-
-
Save mmilosheski/0ec054737f652bca9356 to your computer and use it in GitHub Desktop.
wordpress add to database table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// HTML PAGE TEMPLATE SHOULD HAVE THIS CODE (KEEP IN MIND THAT THE INSERT.PHP IS IN THE TEMPLATE DIR | |
<form action="<?php echo get_template_directory_uri(); ?>/insert.php" method="post"> | |
Name:<input type="text" name="name"/> | |
<input type="submit" name="submit"/> | |
</form> | |
/// THE INSERT.PHP FILE SHOULD HAVE THIS CODE | |
<?php | |
global $wpdb | |
$name = $_POST['name']; | |
$wpdb->insert( 'bank', array( 'name' => $name ), array( '%s' ) ) | |
?> |
when use this code; file name insert.php
insert( 'bank', array( 'name' => $name ), array( '%s' ) ) ?>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fatal error: Call to a member function insert() on a non-object in C:\xampp\htdocs\wordpress\wp-content\themes\poilot\insert.php on line 9
why?