The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End one page both display / handle form wordpress

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #24599

    I have written a php contact form that both displays and handles the form on my contact page in wordpress.

    The contact page file is named contactPage.php and has a url of url/index.php/contact/

    My problem is that every time I test the form, it directs me to my 404 page.

    I have my set my form to both action="contactPage.php" and action="url/index.php/contact/"

    but they both direct me to the 404 page

    Has anyone had any success in having a script both display and handle a form in wordpress?

    Thanks for the time. Code is below:

    Template Name: contactPage

    <?php get_header(); ?>


    if (isset($_POST)) {

    function spam_scrubber($value) {

    $bad = array(‘to:’, ‘cc:’, ‘bcc:’, ‘content-type:’, ‘mime-version:’, ‘multipart-mixed:’, ‘content-transfer-encoding:’);

    foreach ($bad as $v) {
    if (stripos($value, $v) !== false) return ”;
    } // End foreach

    $value = str_replace(array( "r", "n", "%0a", "%0d"), ”, $value);

    return trim($value);

    } //End spam-scrubber

    $scrubbed = array_map(‘spam_scrubber’, $_POST);

    if (!empty($scrubbed) && !empty($scrubbed) && !empty($scrubbed) ) {

    $body = "Name: {$scrubbed}
    nnMessage: {$scrubbed}";

    $body = wordwrap($body, 70);

    mail([email protected]‘, ‘Contact Form Submission’, $body, "From: {$scrubbed}");

    echo ‘<p>Thanks!</p>’;

    $_POST = array();
    } else {

    echo'<p>Please fill out the form completely</p>’;


    <div id="mainCol">

    <div id="mainColInside">

    <div id="contact-area">

    <h3>Contact Eric</h3>

    <form method="post" action="/index.php/contact/">
    <label for="Name">Name:</label>
    <input type="text" name="name" id="Name" />

    <label for="Email">Email:</label>
    <input type="text" name="email" id="Email" />

    <label for="Message">Message:</label><br />
    <textarea name="message" rows="20" cols="20" id="Message"></textarea>

    <input type="submit" name="submit" value="Submit" class="submit-button" />

    <input type="hidden" name="submitted" value="TRUE" />


    <div style="clear: both;"></div>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">

    <?php the_content(‘<p class="serif">Read the rest of this page &raquo;</p>’); ?>
    <?php wp_link_pages(array(‘before’ => ‘<p><strong>Pages:</strong> ‘, ‘after’ => ‘</p>’, ‘next_or_number’ => ‘number’)); ?>

    <?php endwhile; endif; ?>


    <?php get_footer(); ?>


    so you have a contact directory in your index.php file???

    that will be you problem, you can put files into directories, not the other way round.

    you may have it like this:

    root folder
    ——– index.php
    Contact folder
    ———— contact.php

    so your calling of the script should be:
    denotes directory
    denotes file

    also if the file is called contactform.php then you need to call this exact file, not a general contact.

    analogy: phone pepsi and ask to speak to john !!!

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.