search
Homephp教程php手册关于POST和GET的有关问题

关于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 />

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

------解决思路----------------------
你是怎么回事?
你自己都有测试代码的,为什么表单提交时没有打印出 id 的值都不知道呢?
------解决思路----------------------
在修改编辑页面 将get到的id的值放在一个隐藏表单中 一起提交就可以了 。不要用global;
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools