I am in the process of replacing out a Yii form in Yii 1 frameowrk with just a regular php form.
The problem I am having is that, I can't figure out where Yii is looking for the form processor file when put it in the form action.
Right now I have the php file to process the form in the same folder as where the view is being stored. Where should I put the form processor php file so that Yii knows where to look for it?
<form action="contact.php" method="post">
<p><b>Your Name*</b> <input type="text" name="yourname" /><br />
<b>Subject*</b> <input type="text" name="subject" /><br />
<b>E-mail*</b> <input type="text" name="email" /><br />
<b>Body*</b><textarea id="message" name="message"></textarea></p>
<p><input type="submit" value="Submit"></p>
</form>
You have to use Yii routing system, because by default there is only one entry point for the yii application - index.php and you can't invoke your file direcly.
<form action="some/doSomething" method="post" >
<p><b>Your Name*</b> <input type="text" name="yourname" /><br />
<b>Subject*</b> <input type="text" name="subject" /><br />
<b>E-mail*</b> <input type="text" name="email" /><br />
<b>Body*</b><textarea id="message" name="message"></textarea></p>
<p><input type="submit" value="Submit"></p>
</form>
And then in your controller:
class SomeController extends CController
{
public function actionDoSomething()
{
\Yii::import('path.to.your.contact.php');
$yourname = \Yii::app()->request->getPost('yourname');
$subject = \Yii::app()->request->getPost('subject');
$email = \Yii::app()->request->getPost('email');
$message = \Yii::app()->request->getPost('message');
// run you methods from contact.php
}
}