


PHP code to verify whether the username exists before registering the page_PHP tutorial
reg.php
error_reporting(0);
//不让PHP报告有错语发生。If it is not closed, there will be a typo like this Warning: preg_match() will not appear if it is closed
session_start();
header("Cache-control: private");
$conn = @ mysql_connect( "localhost","root","")or die("Database connection error");
mysql_select_db("bbs",$conn);
mysql_query("set names utf8");
if ($_POST['submit'])
{
$username = $_POST["username"];
$sql="select userName from user_info where userName='$username'";
// echo $sql;
$query=mysql_query($sql);
$rows = mysql_num_rows($query);
if($rows > 0){
echo "";
}else{
$user_in = "insert into user_info (username,pass,sex,qq,email,img) values ('$_POST[username]',md5('$_POST[pass]'),'$_POST[sex]','$_POST[ qq]','$_POST[email]','$_POST[img_select]')";
//echo $user_in;
mysql_query($user_in);
echo "";
}
//javascript:history.go( -1)
}
?>
func.js
//Change the image according to the drop-down box
function img_change(thisObj){
var imgsrc = "/bbs/img/"+ thisObj.value+".gif";
document.getElementById ("tx_change").src=imgsrc;
}
//Check whether all meet the registration requirements
function check_reg()
{
if(check_len() && check_pass() && check_email () && check_qq())
{
return true;
}else{
return false;
}
}
//Check the password length cannot be less than 6
function check_len(thisObj){
if(thisObj.value.length==0)
{
document.getElementById('show_pass').innerHTML="Password cannot be empty";
return false;
}else{
if (thisObj.value.length<6)
{
document.getElementById('show_pass').innerHTML="Password length is not less than 6";
return false;
}
document.getElementById('show_pass').innerHTML="";
return true;
}
}
//Check two password inputs Is it consistent?
function check_pass(thisObj){
var psw=document.getElementById('pass');
if(psw.value.length==0)
{
document.getElementById ('show_pass').innerHTML="Password cannot be empty";
return false;
}else{
document.getElementById('show_pass').innerHTML="";
if (thisObj .value!=psw.value)
{
document.getElementById('show_repass').innerHTML="The password entered twice was incorrect";
return false;
}
document. getElementById('show_repass').innerHTML="";
return true;
}
}
//Check whether the email is correct
function check_email(thisObj){
var reg= /^([a-zA-Zd][a-zA-Z0-9_]+@[a-zA-Zd]+(.[a-zA-Zd]+)+)$/gi;
var rzt=thisObj.value.match(reg);
if(thisObj.value.length==0){
document.getElementById('show_e').innerHTML="Email cannot be empty";
return false;
}else{
if (rzt==null)
{
document.getElementById('show_e').innerHTML="Email address is incorrect";
return false;
}
document.getElementById('show_e').innerHTML="";
return true;
}
}
//Check whether the qq format is correct
function check_qq (thisObj){
var qq=document.getElementById('qq').value;
var reg=/^d+$/;
if(qq.search(reg))
{
document.getElementById('show_qq').innerHTML=" QQ can only be numbers";
return false;
}else{
document.getElementById('show_qq').innerHTML="";
return true ;
}
}
Author: sweet__smile

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.
