WordPress.org

Ready to get started?Download WordPress

Forums

How to use form action HTML embed via text input and where to store files? (22 posts)

  1. Paul
    Member
    Posted 1 year ago #

    I have embedded some form code that works using a flat HTML file structure.

    At current the submit action is searching for http://current/route/to/contact-test/phpmailersub.php.

    I wish to know where to store the PHPMailer files and how to action them properly. Like I said before the method and code I used previous with a flat HTML file structure worked fantastically, so I must be missing something using a WordPress platform.

    My current code:
    <form class="contact_form" form action="phpmailersub.php" method="post" enctype="multipart/form-data" name="contact_form" onsubmit="return validateForm()">

    Your help would be hugely appreciated! :)

  2. ubaidullahbutt
    Member
    Posted 1 year ago #

    Ok, I got the point.

    Go to your file phpmailersub.php.

    On the top write
    <?php
    /* Template Name: Php Mailer */
    ?>

    Then go to the admin side, and create new page, on the right side, you will see a dropdown of default template. Select Php Mailer and save the page.

    Now your code will be like that

    <form class="contact_form" form action="URL_To_the_page" method="post" enctype="multipart/form-data" name="contact_form" onsubmit="return validateForm()">

    URL_To_the_page will be url for that page you created.

  3. ubaidullahbutt
    Member
    Posted 1 year ago #

    Or use like that if you don't want to create page

    <form class="contact_form" form action="<?php bloginfo('template_url'); ?>/phpmailersub.php" method="post" enctype="multipart/form-data" name="contact_form" onsubmit="return validateForm()">

  4. Paul
    Member
    Posted 1 year ago #

    Thanks man this has been driving me nuts. I will try option 2 as I already have the page I wish to use it in. I literally just wish to know where the best place to store the file is and then what goes into form action="".

    So hopefully your method is as easy to implement as it sounds.

  5. ubaidullahbutt
    Member
    Posted 1 year ago #

    If you will work through first option, then you will have to store file in the root theme folder.

    If you are using theme folder, you can place file wherever you want.

  6. Paul
    Member
    Posted 1 year ago #

    I just get the same 404 error - file not found... I do not know where to store the file, just say plugins... but then even when I enter the path into form action="" it still cannot find the file.

    http://damtech.it/demo/etap/wp-content/plugins/phpmailersub.php

  7. Paul
    Member
    Posted 1 year ago #

    The problem is, im sure, that the URL path in action="" is wrong but that is the correct path copied from the FTP client, my lack of expertise is to blame.

  8. Paul
    Member
    Posted 1 year ago #

    http://damtech.it/demo/etap/contact-test/%3C?php%20bloginfo%28%27http://damtech.it/demo/etap/wp-content/plugins/phpmailersub.php%27%29;%20?%3E%3Cp%3E/phpmailersub.php

    That's what I get upon submit... obviously its not looking in the correct place but how do I rectify this problem?

  9. Andrew
    Forum Moderator
    Posted 1 year ago #

    What did your original code:

    <form class="contact_form" form action="phpmailersub.php" method="post" enctype="multipart/form-data" name="contact_form" onsubmit="return validateForm()">

    Produce? Was it the same 404 error?

  10. Paul
    Member
    Posted 1 year ago #

    No it found phpmailersub.php which used class.phpmailer.php which were stored in the same folder sent then the two emails, totally successfully, which is why I am so confused about this.

    The code I used was a flat HTML type directory structure. At present the phpmailersub.php and class.phpmailer.php are stored in http://damtech.it/demo/etap/wp-content/plugins/phpmailersub.php.

  11. Andrew
    Forum Moderator
    Posted 1 year ago #

    I think this is something you need to discuss with your hosting providers as we cannot see your directories.

  12. Paul
    Member
    Posted 1 year ago #

    well I pasted that code directly from the FTP. Its definitely the correct path.

  13. Andrew
    Forum Moderator
    Posted 1 year ago #

    What is the issue, can you clarify please?

  14. Paul
    Member
    Posted 1 year ago #

    Right my friend...

    I wish to action some PHP script using PHPMailer. It sends the message and an autoresponse containing various attachments. The script works fantastically using plain HTML. (Possibly because the page and script are stored in the same folder, I dunno)

    I have stored both phpmailersub.php and class.phpmailer.php in http://damtech.it/demo/etap/wp-content/plugins/phpmailersub.php

    My code to action the form looks like this:

    <form class="contact_form" action="<?php bloginfo('http://damtech.it/demo/etap/wp-content/plugins/'); ?><p>/phpmailersub.php" enctype="multipart/form-data" method="post" name="contact_form" onsubmit="return validateForm()">
    FIELDS
    </form>

    When I action the form I just get a 404 error and at the following URL: http://damtech.it/demo/etap/contact-test/%3C?php%20bloginfo%28%27http://damtech.it/demo/etap/wp-content/plugins/phpmailersub.php%27%29;%20?%3E%3Cp%3E/phpmailersub.php (which obviously isnt where this file is).

    I realise there is a lot of content here but it is the only way to articulate what I mean. Thanks for your help buddy.

  15. esmi
    Forum Moderator
    Posted 1 year ago #

    In order to pull this off, you would have to - effectively - write your own custom plugin.

  16. Andrew
    Forum Moderator
    Posted 1 year ago #

    I don't see how you can use bloginfo like that.
    Look at its function reference http://codex.wordpress.org/Function_Reference/bloginfo .

    Why do you need to use bloginfo at all?
    Btw this url:

    http://damtech.it/demo/etap/wp-content/plugins/

    Needs to point to a PHP file.

  17. Paul
    Member
    Posted 1 year ago #

    @Andrew Yeah it was just a suggestion from a guy on the stack wordpress forum it pointed to a bit of template code he told me to put in phpmailersub.php. I just had action="phpmailersub.php" originally which didnt work either. How do I point it?

    @esmi Its just so simple using normal HTML. That was a suggestion by another member but I really do not have the skills to write a plugin.

    Any other options? I just need form data to send to address A and an auto response with a fixed message and an attached .pdf file.

  18. esmi
    Forum Moderator
    Posted 1 year ago #

    Its just so simple using normal HTML.

    Which you are now trying to use in a dynamic content management system. If you cannot write the code yourself, perhaps you could look for a suitable existing plugin?

  19. Paul
    Member
    Posted 1 year ago #

    @esmi It must be the way the files are structured then.

    Could I not trick it somewhere and give phpmailersub.php the permanent link of: http://damtech.it/demo/etap/wp-content/plugins/phpmailersub.php?

    I guess I could try and find a plugin but it just seemed a shame when I had the exact code write there.

  20. esmi
    Forum Moderator
    Posted 1 year ago #

    No - you cannot "trick" WordPress into doing anything reliably.

  21. ubaidullahbutt
    Member
    Posted 1 year ago #

    Paul, please store your phpmailersub.php file in your theme folder, not in plugin folder :)

  22. jessy.loran
    Member
    Posted 7 months ago #

    <?php $plugins_url = plugins_url( 'gs-subscribe-search/subscribe.php' , dirname(__FILE__) ); ?>
    <form action="<?php echo $plugins_url ?>" method="post" enctype="multipart/form-data">

Topic Closed

This topic has been closed to new replies.

About this Topic