php传值,界面跳转,数据库连接,查询,读出,写入

这里运用到了HTML5,所以如果浏览器不支持HTML5的话,视频无法播放

//登录界面

<?php   
header("Content-type:text/html;charset=gb2312");   //处理乱码问题
?>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	<title>Login Page</title>
	<link rel="shortcut icon" href="/favicon.ico">
	<link rel="stylesheet" type="text/css" href="js/style.css" />
</head>

<body>
	<form id="login-form" action="b.php" method="post">
		<fieldset>		
			<legend>Log in</legend>			
			<label for="login">用户名</label>
			<input type="text" id="login" name="username"/>
			<div class="clear"></div>		
			<label for="password">密码</label>
			<input type="password" id="password" name="password"/>
			<div class="clear"></div>
			<br />
			<br><br>
			<input type="submit" style="margin: -20px 0 0 287px;" class="button" name="commit" value="登录"/>	
		</fieldset>
	</form>	
<br /><br />
<br />
<br />
<br />
<br />
</body>
</html>
//登陆后跳转到此php界面判断是否登陆成功

<?php
	ob_start();
	$username = $_POST['username'];
	$passwords = $_POST['password'];
	if($username==null||$passwords==null){//此处判断用户名和密码是否为空
		header("location:a.php");//进行跳转
		echo "请确定用户名和密码都已填写";
	}else {
		$sql="select * from userlist where username = '".$username."' and passwords = '".$passwords."'";//sql语句
	}
	class DataBase{
		public $dbhost = "localhost";//以下四行代码为与数据库取得链接
		public $dbuser = "zhanqingchun";
		public $dbpass = "12345679";
		public $dbname = "zhanqingchun";
		function conn(){//判断是否成功连接数据库
			$dbconn = mysql_connect($this->dbhost,$this->dbuser,$this->dbpass) or die("database error!".mysql_error());
			mysql_select_db($this->dbname) or die("can not connect database:".mysql_error());
			return $dbconn;
		}
		function indb($in_sql){//执行sql语句
			$result_indb = mysql_query($in_sql) or die("can not run the sql language:".mysql_error());
			return $result_indb;
		}
	}
	$db = new DataBase();
	$db->conn();
	$k= $db->indb($sql);
	
	if(mysql_fetch_row($k)){//判断用户是否登陆成功	
		$kiss=mysql_fetch_array(mysql_query($sql));
		$sss=$kiss["username"];
		$ss="location:frontvideo.php?kk=".$sss;//设置连接
	    header($ss); 
	}else{
		header("location:music/musicbox.php");//进行跳转
	}
?>

//循环打印出信息
<?php
header("Content-type:text/html;charset=gb2312"); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<?php 
for($num=1;$num<=5;$num++){//使用for循环打印出5个视频
$video = "<a href=\"video.php?id=".$num."\">视频".$num."</a></br>";
echo $video;
$k=$_GET["kk"];//得到用户名
echo $k;//输出用户名
}
?>
<a href="racegame-master/racegame-master/car.php">赛车游戏</a>
<?php echo $showtime=date("Y-m-d H:i:s");//输出系统当前时间?>
</body>
</html>

//播放视频的界面
<?php
$video=$_GET['id'];
$href = "<video src=\"video/mySQL/".$video.".mp4\" width=\"480\" height=\"480\" controls=\"loop\">video</video>";
echo $href;
?>


  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值