WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Plugin Form Submit (3 posts)

  1. Gisha James
    Member
    Posted 4 years ago #

    I am trying to create a simple plugin.
    It is as follows.

    function contactus($content)
    {
    if(strpos($content,'[contactus]')) {

    if($_POST['submit']!="")
    {
    $message = __('Send','contactus');
    }

    $new_content ='<div id="response">';
    if($message) {
    $new_content .= '<p>'.$message.'</p>';
    } else {
    $new_content .='<div class="form">';
    $new_content .='<form method="POST" id="commentform" >';
    $new_content .='<div class="cright"><div class="karea">';
    $new_content .='<label for="comment"><small>Write your Response here :</small></label><textarea name="comment" id="comment" cols="20px" rows="10" tabindex="4"></textarea></p></div>';
    $new_content .='<p><label for="author">Name : </label>';
    $new_content .='<input type="text" name="author" id="author" value=" " size="22" tabindex="1" /></p>';
    $new_content .='<p><label for="email">Mail :<small>(will not be published) </small></label><input type="text" name="email" id="email" value="" size="22" tabindex="2" /></p>';
    $new_content .='<p><label for="url">Website</label><input type="text" name="url" id="url" value=" " size="22" tabindex="3" /></p>';
    $new_content .='<p class="submit"><input name="submit" type="submit" id="submit" tabindex="5" value="'.__('Send','contactus').'" />';
    $new_content .='</p>';
    $new_content .='</div>';
    $new_content .='</form>';
    $new_content .='</div>';
    }
    $new_content .='</div>';

    $content = str_replace('[contactus]',$new_content,$content);
    }
    return $content;
    }
    add_filter('the_content','contactus');

    Eventhough the contact form appears, after submission page does not print "Send"

    I am learning plugin creation. Any help will be appreciated.

  2. Gisha James
    Member
    Posted 4 years ago #

    I just want to know how the variable can be retrieved when someone submits a form on a page. How to code that plugin part.

    The above code displays the form, but when submit is pressed, nothing is showing up.

    Any help will be appreciated.

    Thank you

  3. jakepaint
    Member
    Posted 3 years ago #

    As an aside, you know you can do this, right? :

    $new_content .= '<div class="form">
        <form method="POST" id="commentform" >
        <div class="cright"><div class="karea">
        etc etc

    You don't need to put $new_content .= on every newline.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.