- 爱易网页
-
PHP教程
- 基于mysql的论坛(3)
日期:2013-01-03 浏览次数:20482 次
#####################
# func.php #########
####################
<?php
require("config.inc.php");
##### 检查用户是否存在 #####
function is_user_exits($name) {
$name=trim($name);
$name=ereg_replace("'","‘",$name);
$name=htmlspecialchars($name);
$SQL="SELECT name FROM user WHERE name='$name'";
$result=mysql_query($SQL) or die(mysql_error());
$row=mysql_fetch_Array($result);
$name=$row[name];
return $name;
}
##### 检查版面是否存在 #####
function is_board_exits($baord){
$sql="select name from boardinfo where name='$baord'";
$result=mysql_query($sql) or die("出现错误");
$row=mysql_fetch_array($result);
$name=$row[name];
return $name;
}
##### 添加新用户 Function #####
function adduser(){
global $name,$sex,$realname,$password,$address,$oicq,$homepage,$phone,$email,$qm,$regtime;
$name=trim($name);
$name=ereg_replace("'","‘",$name);
$password=trim($password);
$name=htmlspecialchars($name);
$realname=htmlspecialchars($realname);
$address=htmlspecialchars($address);
$oicq=htmlspecialchars($oicq);
$homepage=htmlspecialchars($homepage);
$phone=htmlspecialchars($phone);
$email=htmlspecialchars($email);
$qm=htmlencode2($qm);
$regtime=date("Y-m-d H:i:s");
$sql="insert into user (name,sex,realname,password,address,oicq,homepage,score,phone,email,qm,regtime,slaveboard) values('$name','$sex','$realname','$password','$address','$oicq','$homepage','0','$phone','$email','$qm','$regtime','')";
mysql_query($sql) or die(mysql_error());
}
##### URL 重定向 ######
function redirect2($url){
header("Location:$url");
}
##### 创建版面 ######
function create_board_table($name,$chinesename){
$name=trim("$name");
$sql="CREATE TABLE $name(id int(11) NOT NULL AUTO_INCREMENT,title varchar(50) NOT NULL,writer varchar(50) NOT NULL,cont longtext, size int,writetime varchar(20) NOT NULL,hits int(4) DEFAULT '0',good varchar(1),renum int(4) DEFAULT '0',slaveid int(11) DEFAULT '0',fromip varchar(15),PRIMARY KEY (id))";
mysql_query($sql);
$sql="insert into boardinfo (
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。