Я создал сайт в CodeIgniter2, но я не могу заставить работать формы, так как не могу даже понять, как заставить его публиковать! Любая помощь? Вот мой код и формы только на страницах рекомендаций, контактов и поддержки:
Форма:
<div id="mainWhiteBox">
<h3>Tell people about us...</h3>
<p>If you know of a company or individual who need a really great design agency to help them with a project, let them know about us and benefit too. <br /><br />
<span class="customColour">We will give you £50 of Marks & Spencer vouchers for every client you recommend to us who goes on to become a client of xxxxx, it's that simple & there is no limit to the amount of vouchers you can earn!</span></p>
<div id="recommendSomeone">
<?php echo validation_errors(); print_r($_POST);?>
<?php echo form_open('recommend', array('id' => 'recommendForm')); ?>
<label for="friendName">Your Friend's Name</label>
<input type="text" id="friendName" value="<?php echo set_value('friendName'); ?>" />
<label for="friendEmail">Your Friend's Email Address</label>
<input type="email" id="friendEmail" value="<?php echo set_value('friendEmail'); ?>" placeholder="someone@youknow.com" />
<label for="customerName">Your Name</label>
<input type="text" id="customerName" value="<?php echo set_value('customerName'); ?>" />
<label for="customerEmail">Your Email Address</label>
<input type="email" id="customerEmail" value="<?php echo set_value('customerEmail'); ?>" placeholder="you@youremailaddress.com" />
<label for="friendConfirm"><input type="checkbox" id="friendConfirm" value="1" <?php echo set_checkbox('friendConfirm', '1'); ?> />I confirm that I know the person I am recommending above.</label>
<input type="submit" value="Submit Recommendation" />
</form>
<img src="<?=base_url(); ?>images/uploads/<?php echo $images[0]["image_filename"]; ?>" alt="<?php echo $images[0]["image_alt"]; ?>" width="180px" height="300px" class="floatRight" />
</div>
<p class="elevenFont">* Get £50 of Marks & Spencer vouchers per company or person recommended who goes on to open an account with xxxxx.</p>
</div>
<?php include("/home/xxxxx/libraries/application/views/widgets/newsWidget.php"); ?>
<?php include("/home/xxxxx/libraries/application/views/widgets/twitterWidget.php"); ?>
<?php include("/home/xxxxx/libraries/application/views/widgets/quickViewWidget.php"); ?>
<?php include("/home/xxxxx/libraries/application/views/widgets/fbLikePageWidget.php"); ?>
<?php include("/home/xxxxx/libraries/application/views/widgets/getQuoteBarWidget.php"); ?>
<?php include("/home/xxxxx/libraries/application/views/widgets/newsletterSubscribeWidget.php"); ?>
Контроллер:
<?php
class Pages extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('pages_model');
}
public function view($page = 'home')
{
if ( ! file_exists('/home/urbanfea/libraries/application/views/pages/'.$page.'.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$data['title'] = $this->pages_model->getTitle($page);
$data['showcase'] = $this->pages_model->getShowcase();
$data['news'] = $this->pages_model->getNewsWidgetContent();
$data['quote'] = $this->pages_model->getQuoteFromBank();
$data['images'] = $this->pages_model->getPageImageArray($page);
$data['PageStraplines'] = $this->pages_model->getStraplines($page);
$data['serverStatus'] = $this->pages_model->getIssue("1");
if($page == "support")
{
$this->load->view('templates/supportHead', $data);
}
else
{
$this->load->view('templates/head', $data);
}
if($page == "recommend" || $page == "contact-us" || $page == "support")
{
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('friendName', 'Friend\'s Name', 'required');
$this->form_validation->set_rules('friendEmail', 'Friend\'s Email Address', 'required');
$this->form_validation->set_rules('customerName', 'Customer\'s Name', 'required');
$this->form_validation->set_rules('customerEmail', 'Customer\'s Email Address', 'required');
//$this->form_validation->set_rules(FriendConfirm', 'Confirm you know the person', 'required');
if ($this->form_validation->run() === true)
{
$this->load->view('templates/formSuccess', $data); echo "a";
}
elseif($this->form_validation->run() === false && validation_errors() != "")
{
$this->load->view('templates/formError', $data); echo "b";
}
elseif($this->form_validation->run() === false)
{
echo "c";
}
}
$this->load->view('templates/header', $data);
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);
}
}
?>
Редактировать
Вот маршруты в моем роутере:
$route['404_override'] = '';
$route['user/(:any)'] = 'user/view/$1';
$route['user'] = 'user/login';
$route['our-work/(:any)'] = 'our_work/view/$1';
$route['our-work'] = 'our_work';
$route['what-we-do/(:any)'] = 'what_we_do/view/$1';
$route['what-we-do'] = 'what_we_do';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';