php常用基础代码Word格式文档下载.docx
- 文档编号:7960240
- 上传时间:2023-05-09
- 格式:DOCX
- 页数:14
- 大小:18.67KB
php常用基础代码Word格式文档下载.docx
《php常用基础代码Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《php常用基础代码Word格式文档下载.docx(14页珍藏版)》请在冰点文库上搜索。
mysql_select_db("
soft"
$conn)ordie("
数据库连接失败!
$select="
select*fromadmin_infowhereadmin_user='
$user_name'
andadmin_password='
$user_password'
;
$result=mysql_query($select,$conn);
$row=mysql_num_rows($result);
if($row==1){
$_SESSION["
admin"
]="
yes"
id"
$user_name"
echo"
script>
alert('
登陆成功!
'
)<
/script>
echo"
location.href='
editor.htm'
}else{
登陆失败!
history.back();
}
/body>
/html>
注册代码
session_start();
include"
../conn/conn.php"
$UserName=$_POST[txt_regname];
$sql=mysql_query("
select*fromtb_userwhereregname='
$UserName'
$result=mysql_fetch_array($sql);
if($result!
=false){
echo("
用户名已被注册!
history.go(-1);
exit();
$_SESSION[username]=$_POST[txt_regname];
$regname=$_POST[txt_regname];
$regrealname=$_POST[txt_regrealname];
$regpwd=$_POST[txt_regpwd];
$regbirthday=$_POST[txt_birthday];
$regemail=$_POST[txt_regemail];
$regcity=$_POST[txt_province].$_POST[txt_city];
$regico=$_POST[txt_ico];
$regsex=$_POST[txt_regsex];
$regqq=$_POST[txt_regqq];
$reghomepage=$_POST[txt_reghomepage];
$regsign=$_POST[txt_regsign];
$regintroduce=$_POST[txt_regintroduce];
$ip=getenv(REMOTE_ADDR);
$INS=mysql_query("
InsertIntotb_user(regname,regrealname,regpwd,regbirthday,regemail,regcity,regico,regsex,regqq,reghomepage,regsign,regintroduce,ip,fig)Values('
$regname'
'
$regrealname'
$regpwd'
$regbirthday'
$regemail'
$regcity'
$regico'
$regsex'
$regqq'
$reghomepage'
$regsign'
$regintroduce'
$ip'
0)"
echo"
alert('
用户注册成功!
window.location='
file.php'
删除代码示例
charset=utf8"
$title=$_POST["
title"
.mysql_error());
$conn)ordie("
mysql_query("
setnamesgb2312;
$sql="
deletefromtb_articlewheretitle='
$title'
$result=mysql_query($sql,$conn);
if($result)
{
echo("
文章删除成功!
location.href=('
}else{
文章删除失败!
}?
数据库连接代码
$conn=@mysql_connect("
"
)ordie("
数据库链接错误"
mysql_select_db("
$conn);
mysql_query("
setnamesgb2312"
相关JS
//JavaScriptDocument
//首页登录验证
functionf_check(form){
if(form.txt_user.value=="
){
alert("
请输入用户名"
form.txt_user.focus();
returnfalse;
}
if(form.txt_pwd.value=="
请输入密码"
form.txt_pwd.focus();
if(form.txt_yan.value=="
请输入验证码"
form.txt_yan.focus();
if(form.txt_yan.value!
=form.txt_hyan.value){
对不起,您输入的验证码不正确!
}
//判断用户的输入是否合法
functioncheck(){
if(myform.txt_regrealname.value=="
alert("
请输入真实姓名!
myform.txt_regrealname.focus();
if(myform.txt_regpwd.value=="
请输入密码!
myform.txt_regpwd.focus();
if(myform.txt_regpwd.value.length<
3){
密码至少为3位,请重新输入!
}
if(myform.txt_regpwd2.value=="
请确认密码!
myform.txt_regpwd2.focus();
if(myform.txt_regpwd.value!
=myform.txt_regpwd2.value){
您两次输入的密码不一致,请重新输入!
if(myform.txt_birthday.value=="
请输入您的生日"
myform.txt_birthday.focus();
if(CheckDate(myform.txt_birthday.value)){
请输入标准日期(如:
1980/05/29或1980-05-29)"
if(myform.txt_regemail.value=="
请输入Email地址!
myform.txt_regemail.focus();
vari=myform.txt_regemail.value.indexOf("
@"
varj=myform.txt_regemail.value.indexOf("
."
if((i<
0)||(i-j>
0)||(j<
0)){
您输入的Email地址不正确,请重新输入!
myform.txt_regemail.value="
if(myform.txt_province.value=="
请选择您所在的省会名称!
myform.txt_province.focus();
if(myform.txt_city=="
请选择您所在的城市名称!
myform.txt_city.focus();
if(myform.txt_ico=="
请选择您喜欢的人物头像!
myform.txt_ico.focus();
}
functionCheckDate(INDate)
{if(INDate=="
)
{returntrue;
subYY=INDate.substr(0,4)
if(isNaN(subYY)||subYY<
=0){
returntrue;
//转换月份
if(INDate.indexOf('
-'
0)!
=-1){separate="
-"
else{
if(INDate.indexOf('
/'
=-1){separate="
/"
else{returntrue;
area=INDate.indexOf(separate,0)
subMM=INDate.substr(area+1,INDate.indexOf(separate,area+1)-(area+1))
if(isNaN(subMM)||subMM<
if(subMM.length<
2){subMM="
0"
+subMM}
//转换日
area=INDate.lastIndexOf(separate)
subDD=INDate.substr(area+1,INDate.length-area-1)
if(isNaN(subDD)||subDD<
if(eval(subDD)<
10){subDD="
+eval(subDD)}
NewDate=subYY+"
+subMM+"
+subDD
if(NewDate.length!
=10){returntrue;
if(NewDate.substr(4,1)!
="
){returntrue;
if(NewDate.substr(7,1)!
varMM=NewDate.substr(5,2);
varDD=NewDate.substr(8,2);
if((subYY%4==0&
&
subYY%100!
=0)||subYY%400==0){//判断是否为闰年
if(parseInt(MM)==2){
if(DD>
29){returntrue;
28){returntrue;
}
varmm=newArray(1,3,5,7,8,10,12);
//判断每月中的最大天数
for(i=0;
i<
mm.length;
i++){
if(parseInt(MM)==mm[i]){
if(parseInt(DD)>
31){
returntrue;
}else{
returnfalse;
}
if(parseInt(DD)>
30){returntrue;
if(parseInt(MM)>
12){returntrue;
returnfalse;
functionopenwin(x){
if(x=="
alert("
请输入用户名!
myform.txt_regname.focus();
}
else{
window.open("
submit_checkuser.php?
x="
+x,"
newframe"
width=300,height=150"
helpstat=false;
basic=false;
functionAddText(NewCode){
document.all("
file"
).value+=NewCode
functionshowsize(size){
if(helpstat){
文字大小标记\n设置文字大小.\n可变范围1-6.\n1为最小6为最大.\n用法:
<
size="
+size+"
这是"
文字<
/size>
}elseif(basic){
AddTxt="
fontsize="
/font>
AddText(AddTxt);
}else{
txt=prompt("
大小"
+size,"
文字"
if(txt!
=null){
AddTxt="
+txt;
AddText(AddTxt);
functionbold(){
加粗标记\n使文本加粗.\n用法:
b>
这是加粗的文字<
/b>
文字将被变粗."
请在这里输入要加粗的文字!
functionitalicize(){
斜体标记\n使文本字体变为斜体.\n用法:
i>
这是斜体字<
/i>
文字将变斜体"
请在这里输入要倾斜的文字!
functionshowcolor(color){
颜色标记\n设置文本颜色.任何颜色名都可以被使用.\n用法:
color="
+color+"
颜色要改变为"
的文字<
/color>
fontcolor="
选择的颜色是:
+color,"
请在这里输入要改变颜色的文字!
if(txt!
=null){
functionshowfont(font){
if(helpstat){
字体标记\n给文字设置字体.\n用法:
font="
+font+"
改变文字字体为"
fontface="
要设置字体的文字"
+font,"
请在这里输入要改变字体的文字!
functionunderline(){
if(helpstat){
下划线标记\n给文字加下划线.\n用法:
u>
要加下划线的文字<
/u>
下划线文字."
用户相关
数据库表
--phpMyAdminSQLDump
--version2.9.2
--
--主机:
localhost
--生成日期:
2010年12月15日02:
47
--服务器版本:
5.0.27
--PHP版本:
5.2.1
--数据库:
`soft`
----------------------------------------------------------
--表的结构`admin_info`
CREATETABLE`admin_info`(
`admin_id`int(3)NOTNULLauto_increment,
`admin_user`varchar(20)collateutf8_unicode_ciNOTNULL,
`admin_password`varchar(20)collateutf8_unicode_ciNOTNULL,
PRIMARYKEY(`admin_id`)
)ENGINE=MyISAMDEFAULTCHARSET=utf8COLLATE=utf8_unicode_ciAUTO_INCREMENT=9;
--导出表中的数据`admin_info`
INSERTINTO`admin_info`VALUES(3,'
Ethnicity'
'
721wyzj'
--表的结构`tb_article`
CREATETABLE`tb_article`(
`id`int(10)NOTNULLauto_increment,
`content`mediumtextNOTNULL,
`author`varchar(20)NOTNULLdefault'
`now`datetimeNOTNULLdefault'
0000-00-0000:
00:
00'
`title`varchar(200)NOTNULL,
PRIMARYKEY(`id`)
)ENGINE=M
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- php 常用 基础 代码
![提示](https://static.bingdoc.com/images/bang_tan.gif)