0

Currently I have an html form where users can enter an address string.

For example, if they enter "74 Egan Drive" in the text box, it will take them to the following URL:

http://example.com/Edit_Address.php?address=74+Egan+Drive

I am trying to use PHP to grab the address and put it inside a form with $_GET['address'], such as:

Echo "<label>Street Address</label><input name=\"address\" type=\"text\" value= ".$_GET['address']."><br>";

But inside the text box, only the number 74 shows up, and not the full address.

What am I doing wrong here?

1

2 Answers 2

1

You forgot the quotes around your HTML value attribute resulting in only the content before the first space being displayed and the rest being ignored as useless HTML attributes.

echo '<label>Street Address</label><input name="address" type="text" value= "'.$_GET['address'].'"><br>';

FYI, I changed the way you used quotes to make this easier to read.

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

1 Comment

Yes, this is exactly what I'm looking for! Thank you for the fast response~
0

You missed to escape the value inside the input text. It should be:

value=\"".$_GET['address']."\"

Try to this full code below:

echo "<label>Street Address</label><input name=\"address\" type=\"text\" value=\"".$_GET['address']."\"><br>";

3 Comments

Welcome. please accept my answer for others to know. thanks
Had to give it to John since he answered first ><
you can check the time we posted. :) anyway, it's just okay. glad i'd helped.

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.