Php 从mySQL搜索中填充表单字段
从本论坛提供的一些非常合理的指导中,我编写了一个php脚本,它允许管理员通过html表单,使用电子邮件地址作为搜索标准来搜索成员记录,并且运行良好 我的问题是在搜索完成后填充html字段中的第一个和姓氏字段。结果显示在单独的网页上,而不是填写相关的表单字段。我相信答案很简单,但在过去的几天里,我一直在努力让它发挥作用,但没有成功 我已经在下面发布了php脚本和html表单 请有人看看这个,告诉我哪里出了问题 非常感谢 PHP脚本Php 从mySQL搜索中填充表单字段,php,mysql,html,Php,Mysql,Html,从本论坛提供的一些非常合理的指导中,我编写了一个php脚本,它允许管理员通过html表单,使用电子邮件地址作为搜索标准来搜索成员记录,并且运行良好 我的问题是在搜索完成后填充html字段中的第一个和姓氏字段。结果显示在单独的网页上,而不是填写相关的表单字段。我相信答案很简单,但在过去的几天里,我一直在努力让它发挥作用,但没有成功 我已经在下面发布了php脚本和html表单 请有人看看这个,告诉我哪里出了问题 非常感谢 PHP脚本 <?php require("phpfile.php");
<?php
require("phpfile.php");
// Opens a connection to a MySQL server
$connection=mysql_connect ("hostname", $username, $password);
if (!$connection) { die('Not connected : ' . mysql_error());}
// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
$email = $_POST['email'];
$result = mysql_query("SELECT * FROM userdetails WHERE emailaddress like '%$email%'");
while($row = mysql_fetch_array($result))
{
echo $row['forename'];
echo $row['surname'];
echo "<br />";
}
?>
地图!
成员密码重置
成员详细信息
电子邮件地址
确认电子邮件
名字
不知道我是否明白
是否要在电子邮件后自动填写姓名?如果是这样,就必须使用AJAX来调用PHP页面
使用jQuery,您可以很容易地做到这一点。您的意思是希望在搜索页面中显示结果,可能是在表单或类似内容的下方?对吗?所以你只需要把你的php代码和一个.php文件中的html代码放在同一个文件中就行了。首先,非常感谢你阅读了我的文章,其次,我为你的混淆道歉。要确认,单击“搜索”按钮后,我希望搜索表单上的“第一个”和“姓氏”字段填充结果。亲切的问候。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Map!</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="layout.css" rel="stylesheet" type="text/css" />
<script src="js/gen_validatorv4.js" type="text/javascript"></script>
</head>
<body>
<h1>Member Password Reset </h1>
<form name="memberpasswordreset" id="memberpasswordreset" method="post" action="search.php">
<div class="title1">
<h2>Member Details </h2>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="26%" height="25"><strong>Email Address </strong></td>
<td width="4%"> </td>
<td width="70%"><input name="email" type="email" id="email" size="50" /></td>
</tr>
<tr>
<td height="25"><strong>Confirm Email</strong></td>
<td> </td>
<td><input name="conf_email" type="email" id="conf_email" size="50" /></td>
</tr>
<tr>
<td height="25"><label>
<input type="submit" name="Submit" value="search" />
</label></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>First Name </strong></td>
<td> </td>
<td><input name="fname" type="text" id="fname" size="30" value="<?php echo $forename; ?>" /> </td>
</tr>
<tr>
<td height="25"><strong>Last Name </strong></td>
<td> </td>
<td><input name="lname" type="text" id="lname" size="30" value="<?php echo $surname; ?>" /> </td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>Password</strong></td>
<td> </td>
<td><input name="pass" type="password" id="pass" size="30" /></td>
</tr>
<tr>
<td height="25"><strong>Confirm Password </strong></td>
<td> </td>
<td><input name="conf_pass" type="password" id="conf_pass" size="30" /></td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>Password Hint </strong></td>
<td> </td>
<td><input name="hint" type="text" id="hint" size="30" /></td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
<script language="JavaScript" type="text/javascript">
// Code for validating the form
var frmvalidator = new Validator("memberpasswordreset");
frmvalidator.addValidation("email","req","Please enter the users email address");
frmvalidator.addValidation("email","email","Please enter a valid email address");
frmvalidator.addValidation("conf_email","eqelmnt=email", "The confirmed email address is not the same as the email address");
</script>
</body>
</html>