Welcome Guest, Not a member yet? Register   Sign In
Can't get my first web site to work
#1

[eluser]Unknown[/eluser]
Hello everyone,
I've been trying to figure this out for the past two hours, but I'm clueless. I'm trying to learn how to use CI and I decided to start with a form that will submit the fields to my DB. But when I go to localhost:8888/index.php/index There is nothing. The only thing that works is the page title, but the form is not displayed. It's like the <?php tag in the post_view isn't working.

In my autoload I have the database added to libraries and the destination and root password are set in the database.php in the config folder.

If anyone could be so nice and explain to me what am I doing wrong I would really appreciate it. Have a look at my code below:


index.php
Code:
<?php
class Index extends CI_Controller {

  public function __construct() {
  
   parent::__construct();
  
  
  }

  public function index() {
  
   $this->load->view('post_view');
  }
  
  public function post() {
  
    $country = $this->input->post('country');
    $region = $this->input->post('region');
    $city = $this->input->post('city');
    $city_area = $this->input->post('city_area');
    $land = $this->input->post('land');
    $price = $this->input->post('price');
    $type = $this->input->post('type');
    $urgent = $this->input->post('urgent');
    $negotiable = $this->input->post('negotiable');
    $lowest_price = $this->input->post('lowest_price');
    $additional_fees = $this->input->post('additional_fees');
    $add_fees_price = $this->input->post('add_fees_price');
    
    $this->Post_model->submit_form($country, $region, $city, $city_area, $land, $price, $type, $urgent, $negotiable, $lowest_price, $additional_fees, $add_fees_price);

  }
}

post_model.php:
Code:
<?php
class Post_model extends CI_Controller {

  public function __construct() {
  
   parent::__construct();
  
  
  }
  
  public function submit_form($country, $region, $city, $city_area, $land, $price, $type, $urgent, $negotiable, $lowest_price, $additional_fees, $add_fees_price) {
  
   $data = array(
    'country' => $country,
    'region' => $region,
    'city' => $city,
    'city_area' => $city_area,
    'land' => $land,
    'price' => $price,
    'type' => $type,
    'urgent' => $urgent,
    'negotiable' => $negotiable,
    'lowest_price' => $lowest_price,
    'additional_fees' => $additional_fees,
    'add_fees_price' => $add_fees_price,
    
   );
  
   return $this->db->insert('land', $data);
  }

}

post_view.php:
Code:
<!DOCTYPE html>
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt; Post | Real&lt;/title&gt;
  &lt;meta charset="utf=8"&gt;
  &lt;link rel="stylesheet" href="style.css" /&gt;
&lt;/head&gt;
&lt;body&gt;
  
  <div class="center">
  
   &lt;?php echo form_open('index/post'); ?&gt;
  
    <div class="login-margin">
    <label for="country">Country</label><br>
    
    &lt;input type="text" name="country" id="field"&gt;&lt;br>
    </div>
    
    <div class="login-margin">  
    <label for="region">Region</label><br>
  
    &lt;input type="text" name="region"&gt;&lt;br>
    </div>
    
    <div class="login-margin">  
    <label for="city">City</label><br>
  
    &lt;input type="text" name="city"&gt;&lt;br>
    </div>
    
    <div class="login-margin">  
    <label for="city_area">City Area</label><br>
  
    &lt;input type="text" name="city_area"&gt;&lt;br>
    </div>
    
    <div class="login-margin">  
    <label for="land">Land</label><br>
  
    &lt;input type="text" name="land"&gt;&lt;br>
    </div>
    
    <div class="login-margin">  
    <label for="price">Price</label><br>
    
    &lt;input type="number" name="price" min="1" max="9999999"&gt;&lt;br>
    </div>
    
    <div class="login-margin">  
    <label for="type">Type</label><br>
  
    &lt;input type="text" name="type"&gt;&lt;br>
    </div>
    
    <div class="login-margin">  
    <label for="urgent">Urgent</label><br>
  
    &lt;input type="checkbox" name="urgent"&gt;&lt;br>
    </div>
    
    <div class="login-margin">  
    <label for="negotiable">Negotiable</label><br>
  
    &lt;input type="checkbox" name="negotiable"&gt;&lt;br>
    </div>
    
    <div class="login-margin">  
    <label for="lowest_price">Lowest Price</label><br>
    
    &lt;input type="number" name="lowest_price" min="1" max="9999999"&gt;&lt;br>
    </div>
    
    <div class="login-margin">  
    <label for="additional_fees">Additional Fees</label><br>
  
    &lt;input type="text" name="additional_fees"&gt;&lt;br>
    </div>
    
    <div class="login-margin">  
    <label for="add_fees_price">Additional Fees Price</label><br>
    
    &lt;input type="number" name="add_fees_price" min="0" max="9999999"&gt;&lt;br>
    </div>
    
    <div class="login-margin">
    &lt;input type="submit" name="post" value="Post"&gt;
    </div>
    
   &lt;/form&gt;
  </div>
&lt;/body&gt;
&lt;/html&gt;

Thank you in addition for your replies.
#2

[eluser]Tpojka[/eluser]
Don't name your class Index - choose another name.
#3

[eluser]Unknown[/eluser]
Class Name and Controller Name "Index" will not work. Change it to something like "Post".




Theme © iAndrew 2016 - Forum software by © MyBB