Jump to content

script.php in action="script.php" returns "broken link"?


Godfrey
 Share

Recommended Posts

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? 

Link to comment
Share on other sites

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?

  • Like 1
Link to comment
Share on other sites

<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. 

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...