Home > Backend Development > PHP Tutorial > php小练习题

php小练习题

WBOY
Release: 2016-06-13 13:05:00
Original
1022 people have browsed it

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>



Copy after login
注册个人信息
学号:
姓名:
密码:
性别:
出生年月:
所学专业:
备注:
兴趣: 听音乐 看小说 上网

connect.php



<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();
	   }
?>

Copy after login

index.php



<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();
		}
	
 
?>

Copy after login

php中include不用#号,,,,,


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template