Jump to content

403 Error on Form Submission


daniel-not-dan
 Share

Recommended Posts

There is a site I'm working on right now and am trying to integrate this contact form from CSS-Tricks.com. 

The page I'm working on is here: http://accentguru.com/development/book-a-session/ (click the green "Ask Me Anything" button half-way down the page).

The "action" for the form is to run contactengine.php, which is in the same /inc/ folder as the contact form pop-up itself, so I have it set up like this: 

<form method="post" action="<?php echo $config->urls->templates; ?>inc/contactengine.php">
 

The only way I can get it to run without a 403 error is to comment out this line in .htaccess:

RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$ [OR]
 

The only reason I figured that out was because the comment above that line says "Block access to any PHP or markup files in /site/templates/". I'm not really up to speed on the ins and outs of the htaccess file otherwise.

Is there anyone who can explain to me why I shouldn't comment this line out (I assume it's important), and if I shouldn't, is there some other way to allow the contactengine.php file to run? And, for that matter, why isn't it running right now?

BTW - I realize there's a handy-dandy form Module that is available for purchase, but I figured it was over and above what was needed for a simple contact form.

Thanks!

Link to comment
Share on other sites

That line is there for a very good reason, you don't want people accessing your template files directly like you just did. don't remove it.

The best way to do what you want is to create a template with that contactengine.php file, and then a page with that template (lat's say you name it "contactengine"). Then you can do this:

<form method="post" action="<?php echo $pages->get("/contactengine/")->url;?>">
  • Like 2
Link to comment
Share on other sites

Btw,

Is there any advantage/disadvantage of using $pages->get()->url; over $config->urls->root? as shown below?

<form method="post" action="<?php echo $pages->get("/contactengine/")->url;?>"> 

versus

<form method="post" action="<?php echo $config->urls->root?>contactengine/">

Thanks

Link to comment
Share on other sites

Btw,

Is there any advantage/disadvantage of using $pages->get()->url; over $config->urls->root? as shown below?

<form method="post" action="<?php echo $pages->get("/contactengine/")->url;?>"> 

versus

<form method="post" action="<?php echo $config->urls->root?>contactengine/">

Thanks

I think first one is cleaner, but both of those will fail, if you change your page's parent. You could try this also: $pages->get(1234)->url where 1234 is page id.

  • Like 2
Link to comment
Share on other sites

Is there any advantage/disadvantage of using $pages->get()->url; over $config->urls->root? as shown below?

If $config->urls->root will suffice for a given situation, it is potentially a lot less overhead to use it. When you access $config->urls->[anything] you are just accessing already-loaded properties. When you access $pages->get($id)->url, you are triggering a page load, if the page isn't already loaded.

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