【发布时间】:2014-06-04 03:49:06
【问题描述】:
我是这方面的新手,我编写了下面的代码来从 MySQL 数据库中获取用户数据并以表格形式显示以进行编辑和保存。问题是,它不起作用。任何帮助将不胜感激。
<html>
<head>
<title> Delegate edit form</title>
</head>
<body>
Delegate update form <p>
<?php
$usernm = "root";
$passwd = "";
$host = "localhost";
$database = "swift";
//$Name=$_POST['Name'];
//$Username=$_POST['User_name'];
//$Password=$_POST['Password'];
mysql_connect($host,$usernm,$passwd);
mysql_select_db($database);
$sql = "SELECT * FROM usermaster WHERE User_name='$Username'";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
$Name = $row['Name'];
$Username = $row['User_name'];
$Password = $row['User_password'];
}
?>
<form action="Delegate_update.php" method="post">
Name
<input type="text" name= "Name" value= "<?php echo $row ['Name']; ?> "size=10>
Username
<input type="text" name= "Username" value= "<?php echo $row ['Username']; ?> "size=10>
Password
<input type="text" name= "Password" value= "<?php echo $row ['Password']; ?>" size=17>
<input type="submit" name= "submit" value="Update">
</form>
</body>
</html>
【问题讨论】:
-
什么不起作用?你得到什么错误?您采取了哪些措施来解决此问题?
-
尽可能使用mysqli而不是mysql
-
你没有关闭你的表单标签,那么它应该如何知道它应该发布什么表单