• i’ve created a plugin (simple form) and this is the shortcode.php file:

    <?php
    add_shortcode('contact_form','contact_form');
    
    function contact_form(){
        if (isset($_POST['submit'])){
            global $wpdb, $table_prefix;
            $name = $_POST['name'];
            $data = array('name'=>$name,'message'=>'message');
            $wpdb->insert($table_prefix.'contact_form',$data,array('%s','%s'));
            echo 'added';
        }
    
        ?>
        <form method="POST" action="" id="contact_form">
            Name: <input type="text" name="name">
            <input type="submit" name="submit" value="submit">
        </form>
    <?php
    }

    when I submit the form, if I write sth in the text field, is says ‘The page doesn’t exist’ but if i leave it empty, it submits the form. what is the problem? I have used this shortcode in a page.

  • The topic ‘error with submitting a form’ is closed to new replies.