php小练习
今天晚上玩了玩php,做了个登录页面,纪念一下。。。
代码:
zhuce.php
<style> .aa{ font-size:20px; font-family:"幼园"; color:blue; text-align:center; } </style> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <?php function _open() { $link=mysql_connect('localhost','root','')or die('连不上服务器'); $query=mysql_select_db('db1',$link); if($query) echo "连接成功"; else echo "连接失败"; mysql_query('set names utf8'); } function _close() { mysql_close(); } ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <?php if(isset($_POST['bt'])) { $id=$_POST['id']; $name=$_POST['name']; $password=$_POST['Password']; $password=md5($password); $sex=$_POST['sex']; $brith=$_POST['birth']; $major=$_POST['major']; $bz=$_POST['bz']; $XQ=$_POST['XQ']; $s1=implode(',',$XQ); include "../connect.php"; _open(); $sql="insert into Student values('$id','$name','$password','$sex','$brith','$major','$bz','$s1')"; if(mysql_query($sql)) echo "插入成功"; else echo"插入失败"; _close(); } ?>