涉及到(java验证,区块链宠物系统APP开发(T:I8O、2853、296O V黎灿)str_replace,md5 cookie htmspecialchar)
源码:
PHP&Mysql简单留言板 (java验证,str_replace,md5 cookie htmspecialchar)
sql:
CREATE TABLE message
(
id
tinyint(2) NOT NULL auto_increment,
user
varchar(25) NOT NULL,
title
varchar(50) NOT NULL,
content
tinytext NOT NULL,
lastdate
date NOT NULL,
PRIMARY KEY (id
)
)ENGENE=InnoDB DEFAULT CHARSET=gbk_chinese_ci AUTO_INCREMENT=1;
Conn.php
$conn = @mysql_connect("localhost","root","2311220");
mysql_select_db("newdb",$conn);
mysql_query("set names 'utf8_general_ci'");
function htmocode($content){
$content =str_replace("\n","
",str_replace(" "," ",$content));
return $content;
}
?>
Head.php
添加留言 | 浏览留言 | 登陆
List.php
include("head.php");
include("conn.php");
?>
标题: 用户: |
内容: |
Add.php
include("head.php");
include("conn.php");
if($_POST['submit']){
$sql="insert into message(id,user,title,content,lastdate) ".
"values('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
mysql_query($sql);
echo "";
}
?>
function CheckPost()
{
if(myform.user.value=="")
{
alert("请填写用户名");
myform.user.focus();
return false;
}
if(myform.title.value.length<5)
{
alert("标题不能少于5个字符!");
myform.title.focus();
return false;
}
}
数据库
Login.php
include("head.php");
include("conn.php");
if ($_GET[out]) {
setcookie("cookie","out");
echo "";
}
if($_POST[id]=='admin'){
$pw=md5($_POST[pw]);
if($pw=='e1bfd762321e409cee4ac0b6e841963c'){
setcookie("cookie","ok");
echo "";
}
}
if($_COOKIE['cookie']!=ok){
?>
function CheckLogin()
{
if(myform.id.value=="")
{
alert("请填写用户名");
myform.user.focus();
return false;
}
if(myform.pw.value=="")
{
alert("密码不能为空!");
myform.title.focus();
return false;
}
}
退出