个人Blog开发学习笔记

来源:互联网 发布:gopro软件中文版 编辑:程序博客网 时间:2024/05/29 05:11

1.在连接数据库时,基本会执行这三步:

mysqli_select_db($conn,'blog');   //选择数据库$retval = mysqli_query($conn,$sql);  //执行sql语句$row = mysqli_fetch_assoc($retval);   //提取数组$row[username];//  为username字段的值

2.在登录form表单提交之前判断text数值是否为空 用onsubmit

<script type="text/javascript">
function check(){
if(document.getElementById('username').value==""&&document.getElementById('password').value==""){
alert('not null');
return  false;
}
return true;
}
</script>

<form action="" method="post">用户名:<input type="text" id="username" name="username" />密&nbsp;码:<input type="text" id="password" name="password" /><input type="submit" value="Submit" /></form>

3.这一点困扰了我很久,查了好多资料,问题就是,当一个页面setcookie了之后,另一个页面无法读取到cookie,究其原因是路径问题,应该是setcookie("user", $user, time()+3600,'/'); 后面要有一个‘/’,此路径需要在你要访问的文件的上一级,如存cookie到 /blog1/View 那么/blog1/View/index.php就可以读的到,/blog1/Controller/index.php就读不到。

原创粉丝点击