Welcome Guest, Not a member yet? Register   Sign In
Newbie Problem in simple MVC login program.....
#1

[eluser]Unknown[/eluser]
Hi guy's,I am new to codeigniter and I am doing simple MVC login program using CI, But not getting output,instead I am getting
Server error HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

MY Controller file studentform.php is as

<?php
class Studentform extends CI_Controller
{
public function index()
{
$this->load->helper("form")

$this->load->library("form_validation");


$this->form_validation->set_rules("first","First Name","required");
$this->form_validation->set_rules("middle","Middle Name","required");
$this->form_validation->set_rules("last","Last Name","required");
$this->form_validation->set_rules("address","Address","required");
$this->form_validation->set_rules("class","Class","required");
$this->form_validation->set_rules("email","E-mail Address","required|valid_email");



if($this->form_validation->run()==false)
{
$this->load->view("studentform_view");
}
else
{ $first=$_POST["first"];
$middle=$_POST["middle"];
$last=$_POST["last"];
$address=$_POST["address"];
$class=$_POST["class"];
$contact=$_POST["contact"];
$email=$_POST["email"];

$data=array("first_name"=>$first,
"middle_name"=>$middle,
"last_name"=>$last,
"address"=>$address,
"class"=>$class,
"contact"=>$contact,
"email"=>$email);
$this->load->model("studentform_model");
$this->studentform_model->insert_address($data);
$this->load->view("studentformsuccess_view");
}
}
}




My View files studentform_view.php and studentformsuccess.php

<html>
<head>
<title> Student</title>
</head>
<?php

echo validation_errors();

echo form_open("studentform");
?>

<label for="first">First Name</label>
&lt;input type="text" name="first"&gt;&lt;br>

&lt;!-- <label for="middle">Middle Name</label>
&lt;input type="text" name="middle"&gt;&lt;br>
--&gt;
<label for="last">Last Name</label>
&lt;input type="text" name="last"&gt;&lt;br>

&lt;!-- <label for="address">Address</label>
&lt;input type="text" name="address"&gt;&lt;br>

<label for="class">Class</label>
&lt;input type="text" name="class"&gt;&lt;br> --&gt;

&lt;!-- <label for="contact">Contact No.</label>
&lt;input type="text" name="contact"&gt;&lt;br> --&gt;

<label for="email">E-mail Address</label>
&lt;input type="text" name="email"&gt;&lt;br>

&lt;input type="submit" name="submit" value="Submit"&gt;
&lt;/form&gt;
&lt;/html&gt;



View file 2 studentformsuccess.php is as

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Student Form Successful!&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<h3> Your Form was successfully submitted!</h3>
<p><a > Add Another Student Details</a></p>
&lt;/body&gt;
&lt;/html&gt;

MY Model File studentform_model.php is

&lt;?php
class studentform_model extends CI_Model
{
public function insert_address($data)
{
$this->load->database();
$this->db->insert("studentform",$data);
}
}




Please look at the code and suggest me where is I am wrong...
Thanks in advance!!!




Theme © iAndrew 2016 - Forum software by © MyBB