重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

php留言板输出数据库 php 留言板 MySQL

php留言板信息插入数据库和从数据库获取信息再输出的代码

?

创新互联是一家专业提供抚宁企业网站建设,专注与成都网站设计、成都网站制作、外贸网站建设H5页面制作、小程序制作等业务。10年已为抚宁众多企业、政府机构等服务。创新互联专业网络公司优惠进行中。

require("Conn.php");

$user=$_POST['user'];

$pwd=$_POST['pwd'];

if(!is_null($_POST['Submit'])){

if($user!=null and $pwd!=null){

$insert="insert into laod(user,pwd) values('$user','$pwd')";

$result=mysql_query($insert,$conn);

if($result){

echo "scriptalert('注册成功!');window.location.href='zhuce.php';/script";

}

else{

echo "scriptalert('注册失败!');window.location.href='zhuce.php';/script";

}

}

else{

echo "scriptalert('用户名或密码不能为空!');window.location.href='zhuce.php';/script";

}

}

else if(!is_null($_POST['Submit1'])){

if($user!=null and $pwd!=null){

$select="select * from laod where user='$user' and pwd='$pwd'";

$num=mysql_query($select,$conn);

if(mysql_num_rows($num)0){

echo "scriptalert('登陆成功!');window.location.href='zhuce.php';/script";

}

else{

echo "scriptalert('该用户不存在');window.location.href='zhuce.php';/script";

}

}

}

?

//zhuce.php 为模板显示页(自己建就好)

php留言板可以把数据提交到数据库,但是读取不了数据怎么办?

1:可以新增数据的话表示数据库连接没有问题

2:请检查mysql里面

asp

表有没有数据

,有的话

code

:

$_sql

=

$conn-query("select

*

from

asp

where

1=1

order

by

date

desc

limit

0,5");

if($_sql

$_sql-num_rows0){

while($_rs

=

$_sql-fetch_array(MYSQL_ASSOC)){

echo

'内容:'.$_rs['content'];

echo

'时间:'.$_rs['date'];

//打印全部

print_r($_rs);

}else{

echo

'没有任何数据';

}

}

//分页的话建议采用分页类:

php留言板输出问题

你要保证数据库与页面的编码一致,最好在每个页面都加上mysql_query("SET NAMES 'GBK'");和header("content-Type: text/html; charset=gb2312");


新闻标题:php留言板输出数据库 php 留言板 MySQL
网页URL:http://cqcxhl.cn/article/hhpeej.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP