• Hello,
    I am not a perfect programmer but please help me. I want to post a form to my custom database in wordpress. I have tryed a lot of things and normal it is working but in wordpress it don’t. For programming in php I have to add [insert_php] from a plugin otherwise php don’t work in wordpress.

    Please help me.
    Hans

    [insert_php]
    /* Config Values - You need to know these */
    $db_host = 'MYCODE';
    $db_user = 'MYCODE';
    $db_pass = 'MYCODE';
    $db_name = 'MYCODE';
    
    /* Connect to the new database */
    $externalQuery = new wpdb($db_user, $db_pass, $db_name, $db_host);
    
    If($_POST['verzenden']) {
    
    $sStraat=$_POST['Straat'];
    
    if($externalQuery->insert('rittenAdressen', array 'straat' => $sStraat ) == false) wp_die('Database Insertion failed'); else echo 'Database insertion successful<p />';
    
      }
    else
      { 
    
    [/insert_php]
    
    <form action="" method="post">
    
    Streetname: <input type="text" name="Straat">
    
    <input type="submit" name="verzenden" value="verzenden">
    </form>
    
    [insert_php]
    } // end else no post['submit']
    [/insert_php]

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The insert PHP plugin is great for adding PHP on the fly to post content, but it is not required at all to run PHP in WordPress. There’s a number of ways to execute PHP in WordPress, the theme’s functions.php, template files, or you can create your own custom plugin.

    If you have a page functioning outside of WordPress, it will work within WordPress folders just as well because you are not using WordPress functions. If you want the theme styling from WordPress to be part of your form, you could create a page template that displays your functioning form in an iframe. Add a new page based on this template, then use the page’s permalink to display your form.

Viewing 1 replies (of 1 total)
  • The topic ‘Custon database don't work’ is closed to new replies.