2021-10-13

猜数字游戏

效果图

2021-10-13
2021-10-13
2021-10-13

代码

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
<div class="register">
	<form  method="post">
	<fieldset>
	    <legend>填一个1~10的整数</legend>

	    <div class="inp">
		<input id="shuru" type="text" name="shuru"></input><br>
        
		<button>提交</button>
		</div>
		

		</fieldset>
	</form>

	<div class="jg">
	<fieldset>
	<legend>输出结果</legend>
	 <?php
	include('随机数2.php');

   
    if ($shuru==null) {
    	echo "请输入1~10的整数";
    }
	else if ($shuru>$_SESSION['num']){
		echo "您的输入为$shuru<br>";
		echo "猜大了"; 
	}
	else if($shuru<$_SESSION['num']){
		echo "您的输入为$shuru<br>";
	    echo "猜小了"; 
	}
	else if($shuru==$_SESSION['num']){
		echo "您的输入为$shuru<br>";
		echo "恭喜您猜对了";
		$_SESSION['num']=null;
	}
	 ?>
	 </fieldset>
	 </div>
</div>



<style type="text/css">
	.register{
           	width: 400px;
           	margin: 0 auto;
           	
           	padding:10px; 
           }
    input{
    	width: 300px;
    	height: 27px;
    }
    button{
    	width: 309px;
    	height: 32px;
    	margin-top:10px; 
    }
    .inp{
    	text-align: center;
    }
    .jg{
    	margin-top: 5px;
    }
</style>

 
</body>
</html>
<?php
session_start();

$r=rand(1,10);

if (isset($_SESSION['num'])) {

}
else{
	$_SESSION['num']=$r;
}

$shuru=$_REQUEST['shuru'];

?>
上一篇:2020年阿里巴巴实习生线上笔试试题


下一篇:是否有一个python openid应用程序发现库,以将appengine应用程序添加到应用程序市场