Godfrey Posted September 6, 2013 Posted September 6, 2013 I'm trying to setup a mailing form. In my form's action="" attribute, I'm trying to link to my mailing script.However, every time I hit submit, I keep getting redirected to mysite.com/site/templates/path_to_script.php and a blank page that says "Link appears to be broken".This is what I've tried: <form action="<?php echo $config->urls->templates?>mail.php" method="post"> <form action="<?php echo dirname(__FILE__);?>mail.php" method="post"> <form action="<?php echo dirname(__FILE__).'mail.php'?>" method="post"> And I keep getting similar results. Usually, the first method works when I try to include things such as my javascript or css files, but it's not working for this. What do I need to do?
adrian Posted September 6, 2013 Posted September 6, 2013 To load a php file from the templates directory, you must have a page in your page tree that uses that template. So you can either create that page, or you can move the mail.php file outside of the templates directory, assuming that file just processes the form and redirects to another page. Does that make sense and solve the problem? 1
Godfrey Posted September 6, 2013 Author Posted September 6, 2013 Yes, thank you adrian! I chose to move it outside the templates file, and it worked as you said!
ryan Posted September 7, 2013 Posted September 7, 2013 <form action="<?php echo dirname(__FILE__);?>mail.php" method="post"> As a side note, I just wanted to mention that you wouldn't want to use dirname() in a URL like that, as it's giving you a server path, not a URL. Secondly, if you were using dirname(__FILE__); somewhere else, remember that its output does not include a trailing slash like ProcessWire's paths do. So you'd have to add a trailing slash to it's output. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now