Forums

Help - self referenced form script not working (4 posts)

  1. SCARECROW
    Member
    Posted 3 years ago #

    I am trying to use a contact form script, that references $PHP_SELF

    I am using permalinks, and the form is not "finding itself"


    <?
    $form_block = "
    <form method=\"post\" action=\"$PHP_SELF\">
    Your name:<br>
    <input type=\"text\" name=\"name\" size=30 value=\"$_POST[name]\"
    Your email:<br>
    <input type=\"text\" name=\"email\" value=\"$_POST[email]\"size=30
    Comments:<br>
    <textarea name=\"comments\" cols=30 rows=5 wrap=virtual>$_POST[comments]</textarea>
    <input type=\"hidden\" name=\"op\" value=\"ds\">
    <input type=\"submit\" name=\"submit\" value=\"Send Form\">
    </form>";

    if ($_POST[op] != "ds") {
    echo "$form_block";

    } else if ($_POST[op] =="ds") {

    if ($_POST[name] == "") {
    $name_err = "<font color=blue>Please enter your name!</font><br>";
    $send="no";
    }
    if ($_POST[email] == "") {
    $email_err = "<font color=blue>Please enter your email!</font><br>";
    $send="no";
    }
    if ($_POST[comments] == "") {
    $message_err = "<font color=blue>Please enter a comment!</font><br>";
    $send="no";
    }
    if ($send !="no") {
    $msg = "email sent from mywebsite.com\n";
    $msg .="Name: $_POST[name]\n";
    $msg .="Email: $_POST[email]\n";
    $msg .="Comments: $_POST[comments]\n";
    $to = "myname@mysite.com";
    $subject = "Feedback Form";
    $mailheaders = "From: My Website \n";
    $mailheaders .= "Reply-To: $_POST[email]\n";
    mail ($to, $subject, $msg, $mailheaders);
    echo "Mail has been sent!";

    } else if ($send == "no") {
    echo "$name_err";
    echo "$email_err";
    echo "$message_err";
    echo "$form_block";
    }

    }
    ?>

  2. SCARECROW
    Member
    Posted 3 years ago #

    BTW>> I've searched and found http://codex.wordpress.org/Writing_a_Plugin

    but, I've tried that, and it doesn't work either using $SERVER method either.

    [edit]

    I should also mention.. that this is on a "Page" of the site and not inside a post.

  3. moshu
    Member
    Posted 3 years ago #

    Have you tried this plugin?
    http://ryanduff.net/projects/wp-contactform/

  4. SCARECROW
    Member
    Posted 3 years ago #

    Yes.. I've tried two plugins, including that one... problem is, I need to have some pretty complicated forms... and in some cases, more than one on a page.. which tends to blow those plugins out of the water.

    Thanks though...

Topic Closed

This topic has been closed to new replies.

About this Topic