WordPress.org

Forums

HTML form can't launch PHP file (3 posts)

  1. ssergutaboselaw
    Member
    Posted 11 months ago #

    Sorry if I am posting this in the wrong forum.
    I have a feedback type form and a PHP file to send an email, but when I click the submit button on the form, I get an error that the php file can't be opened. I tried opening it directly from my uploads folder and get the same error. I named the file suggestion-send.php. Created it with Notepad. I thought maybe that was the issue, so I copied a current PHP file, renamed it and pasted my text into it. Still won't open. I am logged in with an administrator account. This is for a company intranet - not a blog.

    If you need the code it is:
    FORM:
    <form method="post" name="myemailform" action="http://starthere.boselaw.com/wp-content/uploads/bme-items/suggestion-send.php">
    Enter Name: <input type="text" name="name">
    Enter Email Address: <input type="text" name="email">
    Enter Message: <textarea name="message"></textarea>
    <input type="submit" value="Send Form">
    </form>

    PHP:
    <?php
    $name = $_POST['name'];
    $visitor_email = $_POST['email'];
    $message = $_POST['message'];
    ?>
    <?php
    $email_from = 'administrator@boselaw.com';
    $email_subject = "New Form submission";
    $email_body = "You have received a new message from the user $name.\n".
    "Here is the message:\n $message".
    ?>
    <?php
    $to = "sserguta@boselaw.com";
    $headers = "From: $email_from \r\n";
    $headers .= "Reply-To: $visitor_email \r\n";
    mail($to,$email_subject,$email_body,$headers);
    ?>

  2. Dave Naylor
    Member
    Posted 11 months ago #

    I'm pretty sure your domain doesn't start with starthere.

    Additionally, you're trying to run a PHP script from within the wp-content/uploads directory tree. For that to be possible, your webserver (Nginx) has to be able to execute php files in that location, and that's a big security risk. It's probably disallowed in the server configuration since it returns 403 forbidden.

    Any reason you're not using one of the multitude of ready-made WordPress contact form plugins?

  3. ssergutaboselaw
    Member
    Posted 11 months ago #

    Thanks for the response. I've looked at plugins, but haven't found one I like. I'll keep looking. I just need a simple form that our users can use to make anonymous suggestions.

Reply

You must log in to post.

About this Topic

Tags