index.php:
<?php
if (isset($_POST['userValue'])&&!empty($_POST['userValue'])) {
echo "您输入的是".$_POST['userValue'];
}
else {
echo "没有接收到post值";
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
<title>music</title>
<!-- Bootstrap -->
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<div class="input-group input-group-lg">
<input type="text" class="form-control" name="userValue" placeholder="传到本页面">
<span class="input-group-btn">
<input type="submit" class="btn btn-default" value="GO!">
</span>
</div><!-- /input-group -->
</form>
<form action="demo.php" method="post">
<div class="input-group input-group-lg">
<input type="text" class="form-control" name="userValue" placeholder="传到另一个页面">
<span class="input-group-btn">
<input type="submit" class="btn btn-default" value="GO!">
</span>
</div><!-- /input-group -->
</form>
</div>
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</body>
</html>
demo.php:
<?php
if (isset($_POST['userValue'])&&!empty($_POST['userValue'])) {
echo "您输入的是".$_POST['userValue'];
}
else {
echo "没有接收到post值";
}
?>
<meta charset="utf-8">