Click to See Complete Forum and Search --> : auto-fill text field


kieran.kenny
10-18-2007, 10:23 AM
Just looking for a simple bit of code. I want some of the fext fields on my form to be filled in if a user is already logged in, such as name, email address, etc.

At the moment the name field looks like this but it doesn't work:

<input name="customer_name" type="text" size="40" value="{$customer_name|replace:"\"":"&quot;"}">

Any ideas what I should change to get it to auto-fill from the database?

tca
10-18-2007, 06:48 PM
Assuming:

$result = mysql_query("SELECT * FROM `users` WHERE id = '$user_id' LIMIT 1");
$row = mysql_fetch_array($result);

<input name="customer_name" type="text" size="40" value="<?php echo $row['customer_name']; ?>" />

TC

NightShift58
10-18-2007, 08:00 PM
<input name="customer_name" type="text" size="40" value="{$customer_name|replace:"\"":"&quot;"}">It looks like you're using a template system, based on the sequence that follows value=. If that's the case, you'll have to refer to your documentation.

PointViewMan
10-18-2007, 10:34 PM
I can't offer the coding, but you may want to consider using cookies. After a person enters data into a form (for inclusion into your database) set a cookie with the data for the fields you will want to recall. Examples for setting cookies with various methods are all over the net.