Support » Plugins » Hacks » Submit data into mysql database using wordpress?

  • I’m having trouble figuring out a way to insert data into my own mysql database setup within wordpress. What am I doing wrong?

    global $wpdb;
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $address = $_POST['address'];
    $table_name = $wpdb->prefix . 'customers';
    $wpdb->insert( $table_name,
    array( 'name' => $name,
    'email' => $email,
    'phone' => $phone,
    'address' => $address),
    <form type="post" action="cars-3/" >
    <label for="name">Name:</label>
    <input name="name" type="text" />
    <label for="email">Email:</label>
    <input name="email" type="text" />
    <label for="phone">Phone:</label>
    <input name="phone" type="text" />
    <label for="address">Address:</label>
    <input name="address" type="text" />
    <input type="submit">
    <div id="feedback"></div>
Viewing 1 replies (of 1 total)
  • Hard to tell without more informations. Is $address really a decimal number? Do you get any error (hint: set WP_DEBUG to true)? Do you get an id via $wpdb->insert_id? Have you tried $wpdb->print_error()? …

Viewing 1 replies (of 1 total)
  • The topic ‘Submit data into mysql database using wordpress?’ is closed to new replies.