【发布时间】:2017-04-24 22:39:47
【问题描述】:
所以我有这个网页:
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/inputstyle.css">
<title>Database Input</title>
</head>
<body>
<h1> Database Input Page </h1>
<p> Here you can input to the Database </p>
<a href="View.html">View Database.</a>
<form submit="submit.php" method="post">
<p>First Name: <input type="text" name="firstname" /></p>
<p>Surname: <input type="text" name="surname" /></p>
<p>Age: <input type="text" name="age" /></p>
<p><input type="submit" /></p>
</form>
</body>
还有这个 php 脚本:
<?php
$username="root";
$password="password";
$database="posts";
$firstname=$_POST['firstname'];
$surname=$_POST['surname'];
$age=$_POST['age'];
mysql_connect(serverip,$username,$password);
@mysql_select_db($database) or die( "Unable to connect to Database");
$query = "INSERT INTO input
VALUES('$firstname','$surname','$age')";mysql_query($query);mysql_close();
?>
在我的 mySQL 数据库中,我有数据库“posts”和表input。对于输入表,我只有 3 列,依次为 firstname、surname 和 age。
我需要让它为学校项目工作,但是当我尝试提交表单时,我收到错误405 Not Allowed。这是我第一次使用 php 和 mySQL,所以我不确定我是否犯了任何错误。此外,我所有的网络文件都位于 /usr/share/nginx/html 中,尽管我确实有一个用于 css 的子文件夹。
【问题讨论】:
-
输入的表结构是什么?
-
@Abhik Chakraborty 表结构是 - 名字、姓氏、年龄,如果这就是你的意思?
-
是的,您是否还有其他一些列,例如主键和所有?请发布有关问题的整个结构。
-
嗯也可能是一些服务器配置错误
-
阅读这篇关于主题的文章 => checkupdown.com/status/E405.html @dat_guy 我也删除了我的答案,因为你用我的答案来改变你的变量。如果您在托管网站上,请咨询您的托管服务提供商。