1

I can't change the variable because this is how I receive it from a mail server using IMAP.

$sender = '"Smith, John"';

This is my html:

<td>To:</td>
<td><input name="To" id="to" type="text" size="80" onfocus="changeBg('to','#FFF')"
value= <?php echo $sender; ?> /></td>

this is the output I get:

 To: Smith,John     />

How can I escape the " " or what should I do to remove the "/>" at the end of the output? I've tried every example I found on the net and nothing works. Can please anyone give me help?

I want the text just to be in the input text box like this:

To: Smith, John

Thanks in advance.

EDIT:

When I try the following it works, but the input is not closed at the end(/>)

 <td><input name="To" id="to" type="text" size="80" onfocus="changeBg('to','#FFF')"
 <?php echo 'value='.$sender; ?>" </td>

1 Answer 1

3

Wrap the value with quotes:

<td><input name="To" id="to" type="text" size="80" onfocus="changeBg('to','#FFF')" value="<?php echo $sender; ?>" /></td>

Also, wrap the sender value with addslashes()

Sign up to request clarification or add additional context in comments.

3 Comments

I tried that but I get an empty input field and at the end (outside the text field) " />
There must be some more to the story. Here you can see it in action: codepad.org/FdOJWG5c
From the link you sent me, the variable is closed in quotes. Mine is '"name"'... Also did a edit...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.