首页 > 开发 > PHP > 正文

php页面 表单传递参数实例教程

2024-05-04 21:57:59
字体:
来源:转载
供稿:网友

在php中要传递参数有几种方法,今天我们就讲关于post get二种方法,post用得最多的是利用表单来传参数,get参数一般是url传值居多,下面我们举了二款实例.

post表单传递参数,代码如下:

  1. <html>  
  2. <head>  
  3. </head>  
  4. <body>  
  5. <h3>search</h3>  
  6. <form action="c.php" method="post">  
  7. depart name:<input type="text" size=25 name="depart" value=""><br><br>  
  8. <input type="submit" name="submit" value="search">  
  9. </form>  
  10. </body>  
  11. </html>  

c.php页面,代码如下:

  1. <?php  
  2. $depart=$_post["depart"];  
  3. $q = "select * from info where depart='$depart'";  
  4. ?> 

实例二get 方法传递参数,代码如下:

<a href=www.Vevb.com/a.php?value=www.Vevb.com>传get参数传</a> 

a.php页面代码,代码如下:echo $_get['value']; 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表