• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP连接数据库有关问题

php 搞代码 3年前 (2022-01-23) 20次浏览 已收录 0个评论

PHP连接数据库问题
帮我看下,数据库没内容呐,但是我看着感觉没错呀

<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>
无标题文档

<style type=”text/css”>
body{background-color:#CCCCCC;本文来源gaodai#ma#com搞*!代#%^码$网!搞代gaodaima码
margin:0px;}
.head{height:300px;
text-align:center;}
.gong{height:20px;
background-color:#33CCFF;}
</style>
<body>

用户登录

用户
密码

用户注册

<?php
include “comm.php”;
?>

在线留言-留言板
<meta http-equiv=Content-Type content=”text/html; charset=gb2312″>

<body>
<script type=”text/javascript”>
function check(){
if(myform.name.value==””){
alert(“用户名不能为空!”);
return false;
}
if(myform.pw1.value==”” | myform.pw2.value==””){
alert(“密码不能为空!”);
return false;
}
if(myform.pw1.value!=myform.pw2.value){
alert(“两次输入的密码不一致!”)
return false;
}
return true;
}
</script>
<?php
if(isset($_POST[‘username’])){
$user = $_POST[‘username’];
$pw = md5($_POST[‘pw1’]);

$conn = mysql_connect(“localhost”,”root”,”123456″);
mysql_select_db(“car”);
$sql = “insert into car_user (user_name,pw) values(‘$user’,’$pw’)”;
mysql_query(“set names ‘gb2312′”);
mysql_query($sql,$conn);
mysql_close($conn);
get_show_msg(“left.html”,”注册成功”);
}
?>

第一次密码:
第二次密码

——解决方案——————–
mysql_query($sql,$conn) or die(mysql_error()); //这样有错误提示么
——解决方案——————–
mysql_query($sql,$conn) or die(mysql_error());
——解决方案——————–

HTML code

#js中pw1、pw2未定义,return停掉了,下面的代码就未执行if(myform.pw1.value=="" | myform.pw2.value==""){alert("密码不能为空!");return false;}#改为
#后面添加
#导致php页面$pw = md5($_POST['pw1']); #没有值,不信你echo出来试试需改为:$conn = mysql_connect("localhost","root","123456"); mysql_select_db("car"); $sql = "insert into car_user (user_name,pw) values('$user','$pw')"; mysql_query("set names 'gb2312'"); $res = mysql_query($sql,$conn); #如果sql未执行成功,将错误打印出来 if(!$res) die("SQL:{$sql}
Error:".mysql_error()); if(mysql_affected_rows() > 0) get_show_msg("left.html","注册成功"); else echo "注册失败".mysql_error(); mysql_close($conn);


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP连接数据库有关问题

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址