1

I have form with input text and this form action direct to the same page, now i insert string into input text like "air garden" then submit but after that string in input text become one word that mean it show only "air" not "air garden".

<input type="text" id="sfo_keywords" <?php if($sfo_array['sfo_keywords']) echo "value=".$sfo_array['sfo_keywords'];?> />
1
  • So you are trying to get the first word in a string? "Tiger Prawn" would become "Tiger" for example. Or "PHP Manual rocks" would be just "PHP"? Commented Jun 1, 2016 at 14:03

2 Answers 2

4

This is because you're appending directly to the value= without extra quotes, then in your html code you have something like

<input type="text" value=air garden />

instead of:

<input type="text" value="air garden" />

You can to that to fix it :

<input type="text" id="sfo_keywords" <?php if($sfo_array['sfo_keywords']) echo "value=\"".$sfo_array['sfo_keywords']."\"";?> />
Sign up to request clarification or add additional context in comments.

4 Comments

What the hell!? LOL. You answer two minutes after me with the same explanation and you obtain the upvote? Each day I understand less this community.
However, my upvote to you too. You can do the same ;)
Thank you very much now i understood :)
@M.Ahmed you need to choose the correct answer clicking the check at the left side of them.
3

You've missed the quotes:

<input type="text" id="sfo_keywords" 
       <?php if($sfo_array['sfo_keywords']) {
                echo "value='".$sfo_array['sfo_keywords'];."'";
             }
       ?>  
/>

If you don't wrap the values of the attributes into quotes only the first occurrence will be rendered, and next will be considered attributes.

Example:

 <input class="one two">

Or

 <input class=one two> <!-- here you are the "two" attribute-->

Comments

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.