WordPress.org

Ready to get started?Download WordPress

Forums

How to include a form from theme directory? (8 posts)

  1. dgraves
    Member
    Posted 2 years ago #

    Hey,

    I've built a form on my page which is made for customized ordering, and the page is called order-form. With the permalinks the url is site/order-form

    When I type <form action="mail.php"> it tries to read the url: site/order-form/mail.php

    So I tried typing ./mail.php and ../mail.php... even /../mail.php but nothing really works for me, so how do I proceed?

    I know there's an easy way to do this, but I'm simply not familiar enough with WP to understand how to navigate through the code :)

    I appreciate any help!

  2. keesiemeijer
    moderator
    Posted 2 years ago #

    Try it with get_template_directory_uri():
    http://codex.wordpress.org/Function_Reference/get_template_directory_uri
    or if (mail.php) is in a child theme get_stylesheet_directory_uri():
    http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri

    <form action="<?php echo get_template_directory_uri().'/mail.php' ?>">
  3. dgraves
    Member
    Posted 2 years ago #

    Thank you for your help keesiemeijer but unfortunately it doesn't solve my problem. Now it simply echoes the field values into the addres bar and breaks the form so my layout doesn't work :(

    The problem is that I've tried all the available contact form plugins but none works, because I want the visitor to fill in measures for a certain type of product, and the best way to fill these measures up is by making 18 fields divided into 2 rows, so there's 9 fields on each row. This isn't possible with the plugins (the maximum i've reached with the plugins is 3 fields per row). So I have to do it manually by making them all <td>'s.

    PLEASE tell me if you know another solution or have an idea on how to solve this.

    Thanks!

  4. keesiemeijer
    moderator
    Posted 2 years ago #

    What doesn't work with your form? Does it go to the wrong page after hitting submit?

    try it with:

    <form action="<?php echo get_template_directory_uri().'/mail.php'; ?>" method="post">

    Please provide a link to a page with the form.

    Can you paste and submit the full code of the template file with the form into a pastebin.com and post the link to it here? see the Forum Rules for posting code and using the pastebin.

  5. dgraves
    Member
    Posted 2 years ago #

    Thanks keesiemeijer, I really appreciate your help!

    Well I tried your line of code but it breaks my form somehow :(

    Here's a link of the form (and how it should look, I changed the form action to simply: <form action="mail.php"> because it's the only way that doesn't break the form):
    http://wingmedia.se/springgaiters/order-form/

    Here's the code for mail.php which is under template/mail.php: http://pastebin.com/2pAdGWpA

    And here's the actual form code (it's a little messy because the structure was difficult to get formated correctly): http://pastebin.com/2TR5BgBB

    Thanks again for your help! I deeply appreciate it!

  6. keesiemeijer
    moderator
    Posted 2 years ago #

    A longshot. After your table there is a closing </div>. Remove it

  7. dgraves
    Member
    Posted 2 years ago #

    Thanks again keesiemeijer. I removed the whole div because it's only affecting the "input [media=all]" but the form still breaks apart when I add the line <form action="<?php echo get_template_directory_uri().'/mail.php'; ?>" method="post">

    I did though get it all working by adding this url instead wp-content/themes/colorway/mail.php . But it doesn't seem like a smart way to solve it. Do you have any ideas?

  8. keesiemeijer
    moderator
    Posted 2 years ago #

    but the form still breaks apart

    What do you mean by that? What part breaks, the layout?

    But it doesn't seem like a smart way to solve it. Do you have any ideas?

    Use it, if it does what you want it to.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags