"Mary Ann" in DB, form shows only "Mary"

hi all,

anyone else seen this before. I have 3 or 4 forms in my site and they all do this. if user’s name has a space in it everything after is truncated. names are fine in DB and everywhere else, except when I ECHO them into these damn forms! have looked around quite a bit and have found nothing. why me :frowning:

##################################################

<form id=“loginForm” name=“loginForm” method=“post” action=“set_Minfo.php”>
<fieldset>

<table width=“600” border=“0” align=“left” cellpadding=“2” cellspacing=“0”>
<tr>
<td>
</td>
<tr>
<th>Your First Name* </th>
<td><input name=“firstname” type=“text” class=“textfield” id=“inputtext1” size=25 value= <?php echo $firstname; ?> ></td>
</tr>

#################################################

any thoughts at all would be greatly appreciated !!

Because your HTML is not valid. You need double quotes around attribute values in a tag.

value=“<?php echo $firstname; ?>”

Otherwise you get something like <input value=Mary Ann> and the browser doesn’t know that Ann is part of the value= and not an attribute name itself.

THAT’S IT!!! many MANY thanks Dan!

your time and expertise is TRULY APPRECIATED. wish I could do something for you. if you have some code you need to malfunction, or even crash, I’m here for you :slight_smile:

thanks again & have a good evening!

-mike

m300,

Check your code in an HTML validator, too, and you’ll see that the input tag needs to be closed, too.

Regards,

DK

right.

thank you too DK!

Don’t forget to encode the value too.
You solved the problem when the name contains a space, but what if a user enters a value with " in it? You’ll have the same issue
[fphp]htmlentities[/fphp]

I’m sure a user would never do a thing like that :slight_smile:

good point cranial… will do and THANK YOU!

you guys are appreciated!