php get取不到值解決思路
來源:互聯網
上載者:User
php get取不到值
//自動跳轉
//header("Content-Type:text/html; charset=utf-8");
$type=$_GET['type'];
$ID=$_GET[id];
$url="show_user.php";
$id=$_POST["id"];
//$title= $_POST["title"];
$password = $_POST["password"];
//date_default_timezone_set("Asia/Shanghai");
//php.ini裡加入了date.timezone這個選項,預設情況下是關閉的,也就是顯示的時間(無論用什麼php命令)都是格林威治標準時間,和北京時間正好差8個小時。
//$time = date("Y-m-d H:i:s");//獲得目前時間
$con = mysql_connect("localhost","root","123");
if(!$con)
{
die('串連資料庫失敗!'.mysql_error());
}
//header("Content-Type:text/html; charset=utf-8");
mysql_select_db("test", $con);
mysql_query("set names 'utf8'",$con);
echo "中國";
switch ($type)
{
case edit:
$sql = "update test set id='$id',pass='$password' where id='$id'";
$qu = mysql_query($sql,$con);
if($qu)
{
echo "";
exit;
}
break;
case add:
if(!mysql_query("INSERT INTO test (id,pass) values ('$id','$password')"))
{
die('資料插入失敗!'.mysql_error());
}
else
{
echo "";
exit;
}
break;
case dele:
$sql ="delete from test where id ='$ID'";
$qu=mysql_query($sql,$con);
if($qu)
{
echo "";
exit;
}
break;
}
/*
// 插入資料庫
*/
?>
為什麼$_GET['type']取不到值
------解決方案--------------------
switch ($type)
{
case "edit":
//加引號