Hi All,
This is a post dedicated for creating MVC program using core PHP
////View
<html>
<head>
<form action="controller.php" method=post>
<b> NAME <input type="text" name="name">
ADDRESS <input type="text" name="address">
COURSE<input type="text" name="course"></b>
<input type="submit" name=btnsub value="OK">
</form>
</html>
/////Controller
<?php
include ('model.php');
if(isset($_POST["btnsub"]))
{
echo "entered";
$con=mysql_connect("localhost","root","");
mysql_select_db("mvc",$con);
$s=new student();
$name=$_POST['name'];
$address=$_POST['address'];
$course=$_POST['course'];
$s->insert($name,$address,$course);
//header('location: model.php');
}
?>
/////Model
<?php
class student {
function __construct() {
}
function insert($name,$address,$course ) {
echo "insert worked";
$sql=("insert into student values('$name','$address','$course')");
mysql_query($sql);
}
}
?>
This is a post dedicated for creating MVC program using core PHP
////View
<html>
<head>
<form action="controller.php" method=post>
<b> NAME <input type="text" name="name">
ADDRESS <input type="text" name="address">
COURSE<input type="text" name="course"></b>
<input type="submit" name=btnsub value="OK">
</form>
</html>
/////Controller
<?php
include ('model.php');
if(isset($_POST["btnsub"]))
{
echo "entered";
$con=mysql_connect("localhost","root","");
mysql_select_db("mvc",$con);
$s=new student();
$name=$_POST['name'];
$address=$_POST['address'];
$course=$_POST['course'];
$s->insert($name,$address,$course);
//header('location: model.php');
}
?>
/////Model
<?php
class student {
function __construct() {
}
function insert($name,$address,$course ) {
echo "insert worked";
$sql=("insert into student values('$name','$address','$course')");
mysql_query($sql);
}
}
?>
No comments:
Post a Comment