Support » Fixing WordPress » Want to hand write a form, PHP post function problems

  • Hey all,

    For my portfolio I’ve got a one page site where I’m building my portfolio using entries for new items when added. Other than that though the site is pretty much hand written. I’ve got a contact form I want to add, which has worked well on several other sites I’ve built (non-wordpress) but when you fill in the form and click ‘submit’ it will go to in the url the address listed on the ‘action’ or rather append it to the url.. which i guess is sort of what happens but its meant to scan through the php functions to validate the form and then return the user to the page with a message..

    Is there a reason why this might not work with wordpress? Can give the url if it’s helpful. I’ve tried instead looking at some contact form plugins but these all seem to be embedded into a page/post which isn’t what I want as this will not work with the way I have built this site.


Viewing 7 replies - 1 through 7 (of 7 total)
  • A couple questions:

    1. What is the link to your page?
    2. Are you trying to use a separate script to process the form data, or are you trying to use the same page that displays the form to also process the form?


    The link to the page is..

    I’m using a seperate script which is being loaded with the post function. It’s this which doesn’t seem to be working.

    Here’s what I’m able to see:

    The form is set to post to I navigated to that page to see what would come up, and it looks like the same form is on that page. Since it’s PHP, I obviously can’t see the coding, only what is rendered. Is this particular script set up to check for POST values, process the form data if they are present, or display the form if they are not present? That is a good way to do it, but the reason it’s not working might be that it’s not recognizing that there is data for it to process.

    There are two Javascript errors that I can see. Unfortunately, I’m not as familiar with Javascript as I would like to be, so I’m not sure what you will need to do to take care of these. The first error is a “Parse error” for your script on line 25 in your document. The second error is “ReferenceError: Can’t find variable: prettyForms” on line 261. My guess is that these are not what is causing your form to not work correctly, but they seem to involve the display of the form.

    All things considered, I would look into what is happening with your Processing script. If you want to share specific portions of PHP code, I should be able to help with that.


    The correct address for the script is..

    likewise the prettyforms variable comes from a javascript file found at..

    the problem seems to be is that the php isn’t being read? or even loaded as wordpress I think if it doesn’t register a page will load up the default page (what is displayed on the home page in my case) or a 404 page in its stead.

    So I’ve zipped and uploaded the php and js file if this is any help?

    Hope this helps.

    Yes, the problem is that the PHP isn’t being read, but it’s not being read because it’s not looking in the right place. There is obviously a difference in location between what you posted and what I posted.

    While the concept of the solution is straightforward, actually implementing it can be a little more complicated. In essence, the solution is to just point it to the correct location of the script processing file. Here’s where it can get a bit more complicated: how you actually point it to the right file. If you want to leave all your files in the location that they are currently in, then you need to modify the action attribute of your form to point to the correct processing file. You can do this manually, or even better, you can take advantage of WordPress to do it for you (somewhat). Here’s how you would do that:

    action="<?php get_bloginfo('template_directory'); ?>/assets/inc/"

    Another option is to change how you go about displaying your form altogether. Here’s the method I use on a site that I recently completed. Here’s the link if you want to see it in context. Here’s the code so you can see how it is structured:

     * Template Name: Volunteer
    get_header(); ?>
    <div id="content" class="widecolumn">
       if (isset($_POST['submitted']))
       { ?>
       <div class="post">
       <div id="entry">
       <?php require(''); ?>
       <?php }
          if (isset($_POST['Email']))
             $value = $_POST['Email'];
             $value = strip_tags($value);
             $_POST['Email'] = $value;
          } ?>
       <div class="post">
       <div id="entry">
       <?php require(''); ?>
       <?php } ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    This file is a page template, so I just need to select this template for use with that particular page in WordPress. The reason I can use the two include files without the full path is because I have set up my php.ini file to the location of the include files, and I have set it up so that it is only accessible from the server, not from the website itself. This has the added benefit of being slightly more secure. Also worth noting, it allows the code to be processed by the same php file, which you can see if you look at the source code of the form.

    Hopefully this helps give you some ideas on how to get yours working how you want it to work.

    You sir, are a legend! Thank you!

    No problem! Glad that I could help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Want to hand write a form, PHP post function problems’ is closed to new replies.