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?

John Conde
  • 217,595
  • 99
  • 455
  • 496

2 Answers2

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.

John Conde
  • 217,595
  • 99
  • 455
  • 496
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>";
smzapp
  • 809
  • 1
  • 12
  • 33