Hard coded not seeing php file

Permalink
I have hard coded a form (because I needed the choice of multiple recipients). However, when I test the form it does not link to the mailform.php file on the server and I get a 404 error.

Any ideas how to solve this?

My site:
http://hayesint.co.nz/concrete5.6.2/index.php/contact-us/...

trixiemay
 
bbeng89 replied on at Permalink Reply
bbeng89
I'm not sure how you have this set up, but in the past when I've had to hard-code a form I've always done it as a single page (though a separate page type would work as well). Then I added a controller with a method that handles the form submission. So for your example I would make a page at /single_pages/contact_us. Then make a controller at /controllers/contact_us. Now, in the controller you can add a function (an action) that will handle the form submission. So if the action was called submit it would look like:
class ContactUsController extends Controller {
    public function submit(){
        $email = $this->post('email_address');
        $name = $this->post('name');
        //... grab all fields
        //use concrete5 mail helper to send out email
    }
}

So in that function you just grab all the fields from the POST and then you can use the concrete5 mail helper to send the email:http://www.concrete5.org/documentation/developers/helpers/mail/...

In your single page, in your form action you then can add a link to the submit action:
<form method="post" action="<?php echo $this->action('submit'); ?>">


And that will make sure the correct link is generated so that the form is submitted to the submit() action in the controller.

Hope that helps!