<?php
require_once("E:/PHPWorkSpace/smarty/smarty/Smarty.class.php");
$smarty = new Smarty(); //建立smarty实例对象$smarty
$smarty->template_dir = "E:/PHPWorkSpace/smarty/templates/";//设置模板目录
$smarty->compile_dir = "E:/PHPWorkSpace/smarty/templates_c/"; //设置编译目录
$smarty->config_dir = "E:/PHPWorkSpace/smarty/configs/";
$smarty->cache_dir = "E:/PHPWorkSpace/smarty/cache/";
$smarty->caching = false;
$smarty->left_delimiter = "<{";
$smarty->right_delimiter = "}>";
$name = $_REQUEST['name'];
$studentNum = $_REQUEST['studentNum'];
$department = $_REQUEST['department'];
$collegeMajor = $_REQUEST['collegeMajor'];
$bedroom = $_REQUEST['bedroom'];
$password = $_REQUEST['password'];
$passwordTwo = $_REQUEST['passwordTwo'];
$smarty->assign("check","0");
$conn = mysql_connect("localhost","root","root");
mysql_select_db("news",$conn);
mysql_query("set names 'gbk'");
$result = mysql_query("select * from student where studentNum='$studentNum'");
while($row = mysql_fetch_row($result))
{
$array[]=$row;
}
if(count($array))
{
$smarty->assign("check","2");
}
else
{
if($password == $passwordTwo)
{
$smarty->assign("check","0");
mysql_query("insert into student(name,studentNum,department,collegeMajor,bedroom,password) values ('$name','$studentNum','$department','$collegeMajor','$bedroom','$password')");
}
else
{
$smarty->assign("check","1");
}
}
mysql_close($conn);
$smarty->display("add.tpl");
?>
- 1
- 2
- 3
- 4
- 5
- 6
前往页