Home > Backend Development > PHP Tutorial > PHP practice: a small forum (with backend)_PHP tutorial

PHP practice: a small forum (with backend)_PHP tutorial

WBOY
Release: 2016-07-13 10:32:37
Original
1128 people have browsed it


Register related functions

<?php
//该函数用于处理注册的相关信息验证
require_once '../class/connectMysql.php';

//检查表单是否填写完整
function filled($form_var){
	foreach ($form_var as $key=>$value){
		if (!isset($key) || ($value=='')){
			return false;
		}
		return true;
	}
}

//验证邮箱是否有效
function verifyemail($email){
	if (@ereg('^[a-zA-Z0-9_\.\-]+@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]+$', $email)){
		return true;
	}else {
		return false;
	}
}

//检查用户名是否已经存在
//$connectmysql为数据库连接对象
function verifyname($username,$connectmysql){
	$sql="select * from db_reglog where username='$username'";
	$res=$connectmysql->getRowsNum($sql);
	if ($res !=''){
		return true;
	}else {
		return false;
	}
	
}

//将注册信息写入数据库
//$connectmysql为数据库连接对象
function register($name,$passd,$email,$connectmysql){
	$sql="insert into db_reglog values('$name',sha1('$passd'),'$email','')";
	$res=$connectmysql->uidresult($sql);
	if ($res != ''){
		return true;
	}else {
		return false;
	}
	
}
Copy after login


Directory structure



Forum homepage



Content page

PHP practice: a small forum (with backend)_PHP tutorialDownload address: http://pan.baidu.com/share/link?shareid=3104998419&uk=1094580398


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/755762.htmlTechArticleRegister related functions $value){if (!isset($key) || ($value=='' )){return false;}return true;}}//Verify whether the email is valid function verifyemail($email){if (@ereg('^[a-zA-Z0-9_.-]+@([a-zA ...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template