Home  >  Article  >  php教程  >  Php实现页面传值$_GET的例子

Php实现页面传值$_GET的例子

WBOY
WBOYOriginal
2016-05-25 16:45:491151browse

PHP实例:单表单内容发送和接收

我们都是如果要实现内容发送或者接收我们首先都需要一个表单也就是form标签,下面这个是前端的html代码,代码如下:

<form  action="1.php"> 
<p>Get 发送方式: 
<input type="text" name="wz"/></p> 
<p>Post 发送发送: 
<input type="text" name="wz1"/></p> 
<input type="submit" value="OK"/> 
</form>

后台的php就是从上面的name内的值获取需要的内容,代码如下:

<?php 
    $a = $_GET [&#39;wz&#39;]; 
    if($a==null){echo "对方没输入"."</br>";}else{ 
    echo "我是GET接收方式:".$a."</br>";} 
    $b = $_GET [&#39;wz1&#39;]; 
    if($b==null){echo "对方没输入"."</br>";}else{ 
    echo "我是POST接收方式:".$b."</br>";} 
?>

这里的php意思以get模式来获取标签内属性name里面的值,然而echo 在php中就是打印出来 if就是先加以判断~ 注意:如果表单是post传值我们必须使用$_POST才可以接受数据.

PHP实例:url传值

这个是要发送的php代码,代码如下:

<?php  
    include_once(&#39;zq/db.php&#39;); 
    $sql = "select * from wd_sql"; 
    $query=mysql_query($sql); 
     $i = 1; 
     while ($result = mysql_fetch_array($query)) { 
     $x = $i++; 
       "<br><a href=&#39;del.php?xx=".$result[&#39;id&#39;]."&ccxc=wd_sql&#39;>删除</a>"//在这里实现了传值 
    } 
?>

这个是接收值的php,代码如下:

<?php 
    $uid = $_GET[&#39;xx&#39;]; 
    $db_sql = $_GET[&#39;ccxc&#39;]; 
    if(mysql_query($sql) == 1) 
    {echo "<script>alert(&#39;删除成功!&#39;);history.go(-1);</script>";} 
?>


本文链接:

收藏随意^^请保留教程地址.

Statement:
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