我在服务器上有两个psp文件。第一个 database.psp ,如下所示
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Database</title>
</head>
<body>
<br><br>
<form action="test.psp" method="post">
<table>
<tr>
<td>Database</td>
<td colspan="4">
<select name="database_id" required>
<option value="database_1">Database 1</option>
<option value="database_2">Database 2</option>
</select>
</td>
</tr>
<tr>
<td colspan="5" align="center"><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
<br><br>
</body>
</html>
现在我想在同一个标签中打开 test.psp 文件,该标签显示数据库的数据。这是问题所在。我没有得到 database_id 的数据库字符串。我到现在为止尝试了什么
<%
import cgi
import MySQLdb
db_host = "HOST_NAME"
db_user = "USER_NAME"
db_pass = "PASSWORD"
class MySQL_DB:
# Do some stuff here with MySQL
form = cgi.FieldStorage()
db_name = form.getvalue('database_id')
#form = web.input()
#db_name = form.database_id
#db_name = $_GET['database_id']
#db_name = database_id
DB = MySQL_DB(db_host, db_user, db_pass, db_name)
%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Database values</title>
</head>
<body>
<!-- Show some database output here -->
</body>
</html>
无论如何, db_name 为空。如何获取所选的数据库名称?
非常感谢。