Fill Form Fields From mySQL Search

From some very sound guidance from this forum I’ve put together a php script that allows an administrator, via an html form, to search for member records using the email address as the search criteria and it works fine.The problem I have is populating the first and surname fields in the html fields upon the search being complete. …

via PHP Website Development » Search Results » ajax:

Fill Form Fields From mySQL Search

From some very sound guidance from this forum I’ve put together a php script that allows an administrator, via an html form, to search for member records using the email address as the search criteria and it works fine.
The problem I have is populating the first and surname fields in the html fields upon the search being complete. Instead of filling out the relevant form fields, the results appear on a separate web page. I’m sure the answer is really simple, but I’ve been trying to get this to work over the last couple of days without success.
I’ve posted the php script and html form below.
Could someone perhaps take a look at this please and let me know where I’m going wrong.
Many thanks
PHP Script
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 “
“;

?> HTML Form





Member Password Reset

Member Details

Email Address
Confirm Email
First Name Last Name
Password
Confirm Password
Password Hint



………………………………….

Not sure If I understand…
Do you want to auto-fill the names after the email? If so, you have to use AJAX to call a PHP page.
With jQuery you can do that easily.

For more info: Fill Form Fields From mySQL Search

PHP Website Development » Search Results » ajax

Fill Form Fields From mySQL Search

Share this post:

Related Posts

Leave a Comment