Home > php教程 > php手册 > body text

关于POST和GET的有关问题

WBOY
Release: 2016-06-06 19:42:56
Original
1140 people have browsed it

关于POST和GET的问题 ?php include("conn.php"); include("header.php"); $biaoti=$neirong=$tupian=$id=""; $id=$_GET['id']; $sqlll="select*fromnewswhereid=".$id; $res=mysql_query($sqlll); $row=mysql_fetch_row($res); echo"+++++".$_GET['id']; if(i

关于POST和GET的问题
<br />
<?php<br />
<br />
include("conn.php");<br />
include("header.php");<br />
<br />
$biaoti=$neirong=$tupian=$id="";<br />
$id=$_GET['id'];<br />
$sqlll="select * from news where id =".$id;<br />
$res=mysql_query($sqlll);<br />
$row=mysql_fetch_row($res);<br />
echo "+++++".$_GET['id'];<br />
<br />
if(isset($_POST['submit'])){<br />
	global $id;<br />
	echo "++++".$id;<br />
	$kzm=pathinfo($_FILES['tupian']['name']);<br />
	date_default_timezone_set('Asia/Shanghai');<br />
	$fileName1=date(Ymd_Gis);<br />
	$fileName='upload/'.$fileName1.'.'.$kzm['extension'];<br />
	move_uploaded_file($_FILES['tupian']['tmp_name'],$fileName);<br />
	<br />
	if(empty($kzm['extension'])){<br />
		global $id;<br />
		echo "+++++".$id;<br />
		$sql="UPDATE news SET (biaoti,neirong,riqi) =('$_POST[biaoti]','$_POST[neirong]',now()) WHERE id =".$id;<br />
	}else{<br />
		$sql="UPDATE news【本文来自鸿网互联 (http://www.68idc.cn)】 SET (biaoti,neirong,tupian,riqi) =('$_POST[biaoti]','$_POST[neirong]','$fileName',now()) WHERE id =".$id;<br />
	}<br />
	<br />
	mysql_query($sql);<br />
	<br />
}<br />
<br />
<br />
<br />
?><br />
Copy after login

这是代码,$id放在后面两个if里就都不能输出了,请问是怎么回事,如何解决。

------解决思路----------------------
你是怎么回事?
你自己都有测试代码的,为什么表单提交时没有打印出 id 的值都不知道呢?
------解决思路----------------------
在修改编辑页面 将get到的id的值放在一个隐藏表单中 一起提交就可以了 。不要用global;
Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!