<?php
	session_start();
	include "conn/conn.php";
	$c_sql = "select * from tb_video_user where tb_video_user = '".$_POST[name]."'";
	$c_rst = $conn->execute($c_sql);
	if(!($c_rst == false)){
		if(!$c_rst->EOF){
			echo "<script>alert('用户名重复，请重新输入');history.go(-1);</script>";
			exit();
		}
	}
	if(isset($_POST[regi])){

$head_pictures=$_FILES['head_picture']['size'];
if($head_pictures>2000000){
			echo "<script>alert('您上传的文件超过规定的大小！');history.go(-1);</script>";
			exit();
}
//将图片以二进制格式上传到数据库
$fp=fopen($head_picture,"rb");
$head_picture=addslashes(fread($fp,filesize($head_picture))); 

$sqlstr = "insert into tb_video_user(tb_video_user,tb_video_pass,tb_video_question,tb_video_answer,tb_video_email,tb_video_qq,tb_video_popedom,tb_user_picture) values ('".$_POST[name]."','".$_POST[password]."','".$_POST[question]."','".$_POST[answer]."','".$_POST[email]."','".$_POST[qq]."',0,'".$head_picture."')";
	if($conn->Execute($sqlstr) == false){
		echo "<script>alert('添加错误：".$conn->Errormsg()."');history.go(-1);</script>";
	}
	else{
		echo "<script>alert('恭喜,用户注册成功.请重新登录');window.close();</script>";
	}}
	else{
		echo "<script>alert('!@#$$#@!@#,非法登录');window.close();</script>";
	}
?>