我正在尝试创建一个php表单,我可以将数据输入到MySql表中 我正在使用Xampp服务器,我遇到了一个问题:
Notice: Undefined index: ip in C:\xampp\htdocs\ip_mac_add.php on line 64
Notice: Undefined index: mac in C:\xampp\htdocs\ip_mac_add.php on line 65
Notice: Undefined index: loc in C:\xampp\htdocs\ip_mac_add.php on line 66
Notice: Undefined index: remark in C:\xampp\htdocs\ip_mac_add.php on line 67
代码用于提供值是:
$name='ip_mac_add';
$host='localhost';
$user='root';
$pass='';
$tname='manualFeed';
$conn=mysql_connect($host,$user);
if(!$conn){
echo"Not connected";
}
$db_select=mysql_select_db($name,$conn);
if(!$db_select){
die("database could not be selected ".mysql_error());
}
$ip = $_POST['ip']; /*Line 64*/
$mac = $_POST['mac']; /*Line 65*/
$loc = $_POST['loc']; /*Line 66*/
$remark=$_POST['remark']; /*Line 67*/
if($ip!=""&& $mac!="" && $loc!=""){
$query = mysql_query("SELECT * FROM manualFeed WHERE ip='$ip' && mac ='$mac' && location='$loc' && remark='$remark'");
if(mysql_num_rows($query) >0){
echo '<font color="red" size="5px"><hp>This data already exists in the database!</p></font>';
break;
}
$sql = "INSERT INTO $tname (ip, mac, location, remark) VALUES ('$ip', '$mac', '$loc', '$remark')";
if(!mysql_query($sql)){
die('cannot insert '.mysql_error());
}
}
我尝试过使用&#39; isset()&#39;但它的回报值是&#39; 1&#39;并且该值已输入数据库,因此无法正常工作。