我无法在 php 文件中获取 vars。Echo 什么都不返回,我无法进行查询。请帮我。我知道很少有愚蠢的错误,但我真的很累搜索它..
我有一个表格:
<form align="center" method="POST" action="saveuser.php">
<small>Choose person:</small>
<select name="user" id="user" size="1" onchange="loadUserData()">
<option>Please select</option>
<?php
$con = mysql_connect('localhost', 'root', '');
if (!$con) {
die('Connection error: ' . mysql_error());
}
echo 'Connection Success';
mysql_select_db("live", $con);
$sql_query="SELECT name,id FROM res1";
if(!mysql_query($sql_query, $con))
{
die('INSERT Error: ' . mysql_error());
}
$query = mysql_query($sql_query, $con);
$max_row=0;
while ($row = mysql_fetch_assoc($query)){
if ($max_row !=0){
echo "<option value={$row[id]}>{$row[name]}</option>";
}
$max_row=1;
}
mysql_close($con);
?>
</select></br>
<input id="id" type="hidden"/>
<small>Name: </small><input id="name" type="text" size="40" />
<small>Nat: </small><input id="nat" type="text" size="30" />
<small>Licence: </small><input id="licence" type="text" size="10" /></br>
<small>R1: </small><input id="r1" type="text" size="5" />
<small>R2: </small><input id="r2" type="text" size="5" />
<small>R3: </small><input id="r3" type="text" size="5" />
<small>R4: </small><input id="r4" type="text" size="5" />
<small>R5: </small><input id="r5" type="text" size="5" />
<small>R6: </small><input id="r6" type="text" size="5" />
<small>R7: </small><input id="r7" type="text" size="5" /></br>
<small>FO1: </small><input id="f1" type="text" size="5" />
<small>FO2: </small><input id="f2" type="text" size="5" />
<small>FO3: </small><input id="f3" type="text" size="5" /></br>
<button type="submit" name="submit">Save</button>
和 php 文件 saveuser.php:
<?php
$con = mysql_connect('localhost', 'root', '');
if (!$con) {
die('Connection error: ' . mysql_error());
}
//echo 'Connection Success';
mysql_select_db("live", $con);
$id = $_POST["id"];
$name = $_POST["name"];
echo $id;
echo $name;
$sql_query="UPDATE res1 SET name='".$name."' WHERE id='".$id."'";
//,nat,licence,r1,r2,r3,r4,r5,r6,r7,f1,f2,f3 FROM res1 WHERE id='$value'";
$query = mysql_query($sql_query, $con);
mysql_close($con);
//$URL="edit.php";
//header ("Location: $URL");
?>