我正在尝试构建一个html表单并将其连接到正在执行查询并将信息插入mysql数据库的php文件。
这是我的HTML代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add Record Form</title>
</head>
<body>
<form action="/joomla_31/insert.php" method="post">
<label for="MGMT_IP">MGMT IP</label>
<input type="text" name="MGMT_IP" id="MGMT_IP">
</p>
<p>
<label for="Vendor">Vendor</label>
<input type="text" name="Vendor" id="Vendor">
</p>
<p>
<label for="Version">Version</label>
<input type="text" name="Version" id="Version">
</p>
<p>
<label for="GUI_User">GUI User</label>
<input type="text" name="GUI_User" id="GUI_User">
</p>
<p>
<label for="GUI_Pass">GUI Pass</label>
<input type="text" name="GUI_Pass" id="GUI_Pass">
</p>
<input type="submit" value="submit">
</form>
</body>
</html>
这是我的insert.php文件:
<?php
$link = mysqli_connect("localhost", "root", "", "mysql");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$MGMT_IP = mysqli_real_escape_string($link, $_REQUEST['MGMT IP']);
$Vendor = mysqli_real_escape_string($link, $_REQUEST['Vendor']);
$Version = mysqli_real_escape_string($link, $_REQUEST['Version']);
$GUI_User = mysqli_real_escape_string($link, $_REQUEST['GUI User']);
$GUI_Pass = mysqli_real_escape_string($link, $_REQUEST['GUI Pass']);
// attempt insert query execution
$sql = "INSERT INTO `cloud_team` (MGMT IP, Vendor, Version, GUI User, GUI Pass) VALUES (`$customer_number`, `$customer_name`, `$MGMT_IP`, `$Vendor`, `$Version`, `$GUI_User`, `$GUI_Pass`)";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// close connection
mysqli_close($link);
?>
但是每次点击提交按钮我都会得到一个空白页面...... 这就像重定向正确的文件(http://x.x.x.x/joomla_31/insert.php)..但没有执行...没有显示错误..只有空白页