|
controllers中代码 acm.php
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class ACM extends Ci_Controller
{
public function index()
{
$this->load->view('baoming');
}
function baoming()
{
$username=$_POST['username'];
$xuehao=$_POST['xuehao'];
$sushe=$_POST['sushe'];
$telephone=$_POST['telephone'];
$QQ=$_POST['QQ'];
$zhuanye=$_POST['zhuanye'];
$this->load->model('acm_m');
$arr = array(
'username' => $username,
'xuehao' => $xuehao,
'sushe' => $sushe,
'telephone' => $telephone,
'QQ' => $QQ,
'zhuanye' => $zhuanye
);
$this->acm_m->baoming_insert($arr);
if ( $this->db->affected_rows() > 0)
{
echo"<script>alert('提交成功!返回报名主页');location.href='/www/index.php/acm';</script>";
}
else
{
echo"<script>alert('提交失败!请重新报名');location.href='/www/index.php/acm';</script>";
}
}
}
model 的代码acm_m.php
<?php
class Acm_m extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->load->database();//链接数据库
}
function baoming_insert($arr)
{
$this->db->insert('baoming',$arr);
}
}
?>
view 中的代码 baoming.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>报名网站</title>
<meta name="description" content="这是一个 user 页面">
<meta name="keywords" content="user">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="icon" type="image/png" href="assets/i/favicon.png">
<link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
<meta name="apple-mobile-web-app-title" content="Amaze UI" />
<link rel="stylesheet" href="../AmazeUI-2.2.1/assets/css/amazeui.min.css"/>
<link rel="stylesheet" href="../AmazeUI-2.2.1/assets/css/admin.css">
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.amazeui.org/amazeui/2.2.1/js/amazeui.min.js"></script>
<script type="text/javascript">
$(function(){
var progress = $.AMUI.progress;
$(document).ready(function() {
progress.start();
});
$(window).load(function() {
progress.done();
});
});
</script>
<style>
.doc-ir-demo {
background: #2a2c2e;
}
.doc-ir-demo h1 {
margin-top: -20px;
padding: 10px;
}
.doc-ir-demo a {
display: block;
height: 56px;
width: 210px;
background: url() no-repeat left center;
-webkit-background-size: 210px 56px;
background-size: 210px 56px;
}
</style>
<header class="doc-ir-demo">
<h1><a class="am-text-ir"></a></h1>
</header>
<div class="am-g am-container am-margin-top-xl am-margin-bottom-sm mj_title " data-am-scrollspy="{animation:'slide-left'}">
<h1 class="am-text-center">ACM程序设计大赛</h1>
<small class=".am-sm-text-center">ca.sise.com.cn</small>
</div>
<div class="am-u-sm-center">
<form action="/www/index.php/acm/baoming" name="form" method="post" class="am-form am-form-horizontal" >
<div class="am-form-group">
<label class="am-u-sm-3 am-u-lg-5 am-form-label" ">姓名</label>
<div class="am-u-sm-9 am-u-lg-3 am-u-end">
<input type="text" name="username"id="doc-vld-name" required/>
</div>
</div>
<div class="am-form-group">
<label class="am-u-sm-3 am-u-lg-5 am-form-label">学号</label>
<div class="am-u-sm-9 am-u-lg-3 am-u-end">
<input type="text" name="xuehao" required/ >
</div>
</div>
<div class="am-form-group">
<label class="am-u-sm-3 am-u-lg-5 am-form-label" >宿舍</label>
<div class="am-u-sm-9 am-u-lg-3 am-u-end">
<input type="text" name="sushe" required/>
</div>
</div>
<div class="am-form-group">
<label class=" am-u-sm-3 am-u-lg-5 am-form-label"> 电话</label>
<div class="am-u-sm-9 am-u-lg-3 am-u-end">
<input type="text" name="telephone" required/>
</div>
</div>
<div class="am-form-group">
<label class="am-u-sm-3 am-u-lg-5 am-form-label">Q Q</label>
<div class="am-u-sm-9 am-u-lg-3 am-u-end">
<input type="text" name="QQ" required/>
</div>
</div>
<div class="am-form-group">
<label class="am-u-sm-3 am-u-lg-5 am-form-label">专业</label>
<div class="am-u-sm-9 am-u-lg-3 am-u-end">
<input type="text" name="zhuanye" required/>
</div>
</div>
<div class="am-form-group">
<div class=" am-u-lg-11 am-u-sm-push-3 am-u-lg-push-5 am-u-sm-centered ">
<button type="submit" name='sumbit' class="am-btn am-btn-primary ">提交</button>
<button type="reset" class="am-btn am-btn-default">重置</button>
</div>
</div>
</form>
</div>
<center>
<div class="am-form-group am-vertical-align" style="height:325px">
<div class="am-vertical-align-bottom am-u-lg-2 am-u-lg-centered">
Copyright © 计算机协会CA工作室
</div>
</div>
</center>
</body>
</html>
求大神指导,谢谢
|
|