对于$_post的概述如以下:
1:post初始一个新的url会话并获取一个新的网页,跳转到新的一个页面上去,当然提交少不了FOEM,和sumbit,
在ipunt标签中加上一个名字name,以便在新的一个页面来接收他,在新的页面上打印出效果;
post跳转只适用于PHP的跳转如果用GET来使用跳转将无法实现效果,例如以下代码所示:
1 <html> 2 <head> 3 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> 4 </head> 5 <body> 6 <form action="mro.php" method="post"> 7 <textarea rows="5" name="userName">student more 8 Content</textarea><br> 9 <input type="submit" value="提交"> 10 </form> 11 <?php 12 ?> 13 </body> 14 </html>
1 <html> 2 <head> 3 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> 4 </head> 5 <body> 6 <?php 7 $hg = $_POST["userName"]; 8 $ou = "<pre>$hg</pre>"; 9 echo $ou; 10 ?> 11 </body> 12 </html>
对于$_get的概述如以下:
2:get对于post的用法一样但是作用大为不同,因为他只适用于JS和HTML中的A标签使用进行跳转,
在ipunt标签中加上一个名字name,以便在新的一个页面来接收他,在新的页面上打印出效果;
get跳转只适用于JS,HTML的跳转如果用POST来使用跳转将无法实现效果,例如以下代码所示:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<script type="text/javascript">
function test(){
var u = document.getElementById("user1").value;
location.href="php_request3.php?userName="+u;
}
</script>
</head>
<body>
<form action="php_request2.php" method="get">
姓名: <input type="text" name="userName" id="user1"/> <br/>
密码: <input type="password" name="pwd"/> <br/>
<input type="submit" value="提交"/>
<input type="button" value="提交2" onclick="test()"/>
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<?php
$hg = $_GET["userName"];
$ou = "<pre>$hg</pre>";
echo $ou;
?>
</body>
</html>
浙公网安备 33010602011771号